azure-identity
Loading...
Searching...
No Matches
workload_identity_credential.hpp
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
9#pragma once
10
12#include "azure/identity/detail/client_credential_core.hpp"
14
15#include <azure/core/credentials/token_credential_options.hpp>
16
17#include <string>
18#include <vector>
19
20namespace Azure { namespace Identity {
21 namespace _detail {
22 class ClientAssertionCredentialImpl;
23 } // namespace _detail
24
29 struct WorkloadIdentityCredentialOptions final : public Core::Credentials::TokenCredentialOptions
30 {
35 std::string TenantId = _detail::DefaultOptionValues::GetTenantId();
36
41 std::string ClientId = _detail::DefaultOptionValues::GetClientId();
42
53 std::string AuthorityHost = _detail::DefaultOptionValues::GetAuthorityHost();
54
59 std::string TokenFilePath = _detail::DefaultOptionValues::GetFederatedTokenFile();
60
66 std::vector<std::string> AdditionallyAllowedTenants;
67 };
68
76 class WorkloadIdentityCredential final : public Core::Credentials::TokenCredential {
77 private:
78 std::unique_ptr<_detail::ClientAssertionCredentialImpl> m_clientAssertionCredentialImpl;
79 std::string m_tokenFilePath;
80
81 std::string GetAssertion(Core::Context const& context) const;
82
83 public:
90 Core::Credentials::TokenCredentialOptions const& options
91 = Core::Credentials::TokenCredentialOptions());
92
99
105
114 Core::Credentials::AccessToken GetToken(
115 Core::Credentials::TokenRequestContext const& tokenRequestContext,
116 Core::Context const& context) const override;
117 };
118
119}} // namespace Azure::Identity
Workload Identity Credential supports Azure workload identity authentication on Kubernetes and other ...
Definition workload_identity_credential.hpp:76
Core::Credentials::AccessToken GetToken(Core::Credentials::TokenRequestContext const &tokenRequestContext, Core::Context const &context) const override
Gets an authentication token.
Definition workload_identity_credential.cpp:106
~WorkloadIdentityCredential() override
Destructs WorkloadIdentityCredential.
Client Assertion Credential and options.
Options for workload identity credential.
Definition workload_identity_credential.hpp:30
std::string ClientId
The ClientID of the service principal. Defaults to the value of the environment variable AZURE_CLIENT...
Definition workload_identity_credential.hpp:41
std::string AuthorityHost
Authentication authority URL.
Definition workload_identity_credential.hpp:53
std::string TenantId
The TenantID of the service principal. Defaults to the value of the environment variable AZURE_TENANT...
Definition workload_identity_credential.hpp:35
std::string TokenFilePath
The path of a file containing a Kubernetes service account token. Defaults to the value of the enviro...
Definition workload_identity_credential.hpp:59
std::vector< std::string > AdditionallyAllowedTenants
For multi-tenant applications, specifies additional tenants for which the credential may acquire toke...
Definition workload_identity_credential.hpp:66
Token cache.