Fastly Compute C++ SDK
Loading...
Searching...
No Matches
fastly::secret_store::Secret Class Reference

#include <secret_store.h>

Public Member Functions

fastly::expected< Secretfrom_bytes (std::vector< uint8_t > data)
std::string plaintext ()

Detailed Description

A secret from a secret store.

A secret name has a maximum length of 255 bytes and must contain only letters, numbers, dashes (-), underscores (_), and periods (.).

A secret value has a maximum length of 64 KiB.

Member Function Documentation

◆ from_bytes()

fastly::expected< Secret > fastly::secret_store::Secret::from_bytes ( std::vector< uint8_t > data)

Create a new "Secret" from the given memory. This is not the suggested way to create Secrets; instead, we suggest using SecretStore::get. This secret will NOT be shared with other sessions.

This method can be used for data that should be secret, but is being obtained by some other means than the secret store. New "ecrets" created this way use plaintext/ only, and live in the session's memory unencrypted for much longer than secrets generated by SecretStore::get. They should thus only be used in situations in which an API requires a Secret, but you cannot (for whatever reason) use a SecretStore to store them. As the early note says, this Secret will be local to the current session, and will not be shared with other sessions of this service.

◆ plaintext()

std::string fastly::secret_store::Secret::plaintext ( )

Read the plaintext contents of a secret into memory as a byte buffer.

Once a secret is read into memory, a secret's contents can be repeatedly accessed cheaply.

Examples

Check if fastly::http::HeaderValue matches the contents of a secret.

auto secret{secret_store.get("example").value()};
auto header{request.get_header("example").value()};
if (secret.plaintext() == header) {
std::cout << "you have guessed correctly!";
}
Definition secret_store.h:11

The documentation for this class was generated from the following file: