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
11#include "azure/identity/detail/client_credential_core.hpp"
13
14#include <azure/core/credentials/token_credential_options.hpp>
15
16#include <string>
17#include <vector>
18
19namespace Azure { namespace Identity {
20 namespace _detail {
21 class TokenCredentialImpl;
22 } // namespace _detail
23
28 struct WorkloadIdentityCredentialOptions final : public Core::Credentials::TokenCredentialOptions
29 {
34 std::string TenantId = _detail::DefaultOptionValues::GetTenantId();
35
40 std::string ClientId = _detail::DefaultOptionValues::GetClientId();
41
52 std::string AuthorityHost = _detail::DefaultOptionValues::GetAuthorityHost();
53
58 std::string TokenFilePath = _detail::DefaultOptionValues::GetFederatedTokenFile();
59
65 std::vector<std::string> AdditionallyAllowedTenants;
66 };
67
75 class WorkloadIdentityCredential final : public Core::Credentials::TokenCredential {
76 private:
77 _detail::TokenCache m_tokenCache;
78 _detail::ClientCredentialCore m_clientCredentialCore;
79 std::unique_ptr<_detail::TokenCredentialImpl> m_tokenCredentialImpl;
80 std::string m_requestBody;
81 std::string m_tokenFilePath;
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:75
Core::Credentials::AccessToken GetToken(Core::Credentials::TokenRequestContext const &tokenRequestContext, Core::Context const &context) const override
Gets an authentication token.
Definition workload_identity_credential.cpp:103
~WorkloadIdentityCredential() override
Destructs WorkloadIdentityCredential.
Options for workload identity credential.
Definition workload_identity_credential.hpp:29
std::string ClientId
The ClientID of the service principal. Defaults to the value of the environment variable AZURE_CLIENT...
Definition workload_identity_credential.hpp:40
std::string AuthorityHost
Authentication authority URL.
Definition workload_identity_credential.hpp:52
std::string TenantId
The TenantID of the service principal. Defaults to the value of the environment variable AZURE_TENANT...
Definition workload_identity_credential.hpp:34
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:58
std::vector< std::string > AdditionallyAllowedTenants
For multi-tenant applications, specifies additional tenants for which the credential may acquire toke...
Definition workload_identity_credential.hpp:65
Token cache.