Secrets Manager C++ SDK
The C++ language wrapper for interacting with the Bitwarden Secrets Manager. The SDK, like the Secrets Manager CLI built on-top of it, can be used to execute the following operations:
Authenticate using an access token.
List all secrets, secrets in a project, or projects.
nota
This SDK is a beta release. Therefore, some functionality may be missing.
Setting up a Secrets Manager account prior to using the C++ SDK is recommended. This includes:
Enabling the Secrets Manager CLI.
Setting up machine accounts.
Setting up access tokens.
Locate the C++ GitHub repository here.
Client settings
Initialize BitwardenSettings by passing in api_url
and identity_url
. If these values are not defined in /.env
, Bitwarden will use defaults https://api.bitwarden.com
and https://identity.bitwarden.com
for api_url
and identity_url
respectively.
Bash// Optional - if not stressed, then default values are used
BitwardenSettings bitwardenSettings;
bitwardenSettings.set_api_url("<bitwarden-url>");
bitwardenSettings.set_identity_url("<bitwarden-identity>");
Create new Bitwarden client
Before using the client you must pass the accessToken
:
Bashstd::string accessToken = "<access-token>";
// Optional - argument in BitwardenClient
BitwardenClient bitwardenClient = BitwardenClient(bitwardenSettings);
bitwardenClient.accessTokenLogin(accessToken);
Once the Bitwarden client has been created and authorized, Secrets Manager CLI commands can be passed into the client:
The project command is used to access, manipulate, and create projects. The scope of access assigned to your machine account will determine what actions can be completed with the project
command.
create project
Bashboost::uuids::uuid organizationUuid = boost::uuids::string_generator()("<organization-id>");
ProjectResponse projectResponseCreate = bitwardenClient.createProject(organizationUuid, "TestProject");
list projects
BashProjectsResponse projectResponseList = bitwardenClient.listProjects(organizationUuid);
get project
Bashboost::uuids::uuid projectId = boost::uuids::string_generator()(projectResponseCreate.get_id()); ProjectResponse projectResponseGet = bitwardenClient.getProject(projectId);
update project
Bashboost::uuids::uuid projectId = boost::uuids::string_generator()(projectResponseCreate.get_id());
ProjectResponse projectResponseUpdate = bitwardenClient.updateProject(projectId, organizationUuid, "TestProjectUpdated");
delete projects
BashProjectDeleteResponse projectDeleteResponse = bitwardenClient.deleteProjects({projectId});
The secret command is used to access, manipulate and create secrets. As with all commands, secrets and projects outside your access token's scope of access cannot be read or written-to.
create secret
Bashstd::string key = "key";
std::string value = "value";
std::string note = "note";
SecretResponse secretResponseCreate = bitwardenClient.createSecret(key, value, note, organizationUuid, {projectId});
list secrets
BashSecretIdentifiersResponse secretIdentifiersResponse = bitwardenClient.listSecrets(organizationUuid);
get secret
Bashboost::uuids::uuid secretId = boost::uuids::string_generator()(secretResponseCreate.get_id()); SecretResponse secretResponseGet = bitwardenClient.getSecret(secretId);
update secret
BashSecretResponse secretResponseUpdate = bitwardenClient.updateSecret(secretId, "key2", "value2", "note2", organizationUuid, {projectId});
delete secrets
BashSecretsDeleteResponse secretsDeleteResponse = bitwardenClient.deleteSecrets({secretId});
Sugerir cambios en esta página
¿Cómo podemos mejorar esta página para usted?
Si tiene preguntas técnicas, sobre facturación o sobre el producto, póngase en contacto con el servicio de asistencia.