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.

  • Retrieve a single secret or all secrets in a project.

  • List all secrets, secrets in a project, or projects.

noot

This SDK is a beta release. Therefore, some functionality may be missing.

Requirements

Setting up a Secrets Manager account prior to using the C++ SDK is recommended. This includes:

GitHub Repository

Locate the C++ GitHub repository here.

Basic code examples

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:

Bash
std::string accessToken = "<access-token>"; // Optional - argument in BitwardenClient BitwardenClient bitwardenClient = BitwardenClient(bitwardenSettings); bitwardenClient.accessTokenLogin(accessToken);

Secrets Manager operations

Once the Bitwarden client has been created and authorized, Secrets Manager CLI commands can be passed into the client:

Projects

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

Bash
boost::uuids::uuid organizationUuid = boost::uuids::string_generator()("<organization-id>"); ProjectResponse projectResponseCreate = bitwardenClient.createProject(organizationUuid, "TestProject");

list projects

Bash
ProjectsResponse projectResponseList = bitwardenClient.listProjects(organizationUuid);

get project

Bash
boost::uuids::uuid projectId = boost::uuids::string_generator()(projectResponseCreate.get_id()); ProjectResponse projectResponseGet = bitwardenClient.getProject(projectId);

update project

Bash
boost::uuids::uuid projectId = boost::uuids::string_generator()(projectResponseCreate.get_id()); ProjectResponse projectResponseUpdate = bitwardenClient.updateProject(projectId, organizationUuid, "TestProjectUpdated");

delete projects

Bash
ProjectDeleteResponse projectDeleteResponse = bitwardenClient.deleteProjects({projectId});

Secrets

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

Bash
std::string key = "key"; std::string value = "value"; std::string note = "note"; SecretResponse secretResponseCreate = bitwardenClient.createSecret(key, value, note, organizationUuid, {projectId});

list secrets

Bash
SecretIdentifiersResponse secretIdentifiersResponse = bitwardenClient.listSecrets(organizationUuid);

get secret

Bash
boost::uuids::uuid secretId = boost::uuids::string_generator()(secretResponseCreate.get_id()); SecretResponse secretResponseGet = bitwardenClient.getSecret(secretId);

update secret

Bash
SecretResponse secretResponseUpdate = bitwardenClient.updateSecret(secretId, "key2", "value2", "note2", organizationUuid, {projectId});

delete secrets

Bash
SecretsDeleteResponse secretsDeleteResponse = bitwardenClient.deleteSecrets({secretId});

Make a suggestion to this page

Neem contact op met ons ondersteuningsteam

Voor technische, factuur- en productvragen.

Naam*
Bitwarden account e-mail*
Account e-mail verifiëren*
Product*
Ben je zelf hostend?*
Onderwerp*
Bericht...*

Wolkenstatus

Status controleren

© 2024 Bitwarden, Inc. Voorwaarden Privacy Cookie-instellingen Sitemap

Go to EnglishStay Here