azure-identity
Loading...
Searching...
No Matches
client_certificate_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/credentials.hpp>
15#include <azure/core/credentials/token_credential_options.hpp>
16#include <azure/core/internal/unique_handle.hpp>
17#include <azure/core/url.hpp>
18
19#include <memory>
20#include <string>
21#include <vector>
22
23namespace Azure { namespace Identity {
24 namespace _detail {
25 class TokenCredentialImpl;
26
27 void FreePrivateKeyImpl(void* pkey);
28
29 template <typename> struct UniquePrivateKeyHelper;
30 template <> struct UniquePrivateKeyHelper<void*>
31 {
32 static void FreePrivateKey(void* pkey) { FreePrivateKeyImpl(pkey); }
33 using type = Azure::Core::_internal::BasicUniqueHandle<void, FreePrivateKey>;
34 };
35
36 using UniquePrivateKey = Azure::Core::_internal::UniqueHandle<void*, UniquePrivateKeyHelper>;
37 } // namespace _detail
38
43 struct ClientCertificateCredentialOptions final : public Core::Credentials::TokenCredentialOptions
44 {
55 std::string AuthorityHost = _detail::DefaultOptionValues::GetAuthorityHost();
56
62 std::vector<std::string> AdditionallyAllowedTenants;
63 };
64
70 class ClientCertificateCredential final : public Core::Credentials::TokenCredential {
71 private:
72 _detail::TokenCache m_tokenCache;
73 _detail::ClientCredentialCore m_clientCredentialCore;
74 std::unique_ptr<_detail::TokenCredentialImpl> m_tokenCredentialImpl;
75 std::string m_requestBody;
76 std::string m_tokenPayloadStaticPart;
77 std::string m_tokenHeaderEncoded;
78 _detail::UniquePrivateKey m_pkey;
79
81 std::string tenantId,
82 std::string const& clientId,
83 std::string const& clientCertificatePath,
84 std::string const& authorityHost,
85 std::vector<std::string> additionallyAllowedTenants,
86 Core::Credentials::TokenCredentialOptions const& options);
87
88 public:
98 std::string tenantId,
99 std::string const& clientId,
100 std::string const& clientCertificatePath,
101 Core::Credentials::TokenCredentialOptions const& options
102 = Core::Credentials::TokenCredentialOptions());
103
113 std::string tenantId,
114 std::string const& clientId,
115 std::string const& clientCertificatePath,
117
123
132 Core::Credentials::AccessToken GetToken(
133 Core::Credentials::TokenRequestContext const& tokenRequestContext,
134 Core::Context const& context) const override;
135 };
136
137}} // namespace Azure::Identity
Client Certificate Credential authenticates with the Azure services using a Tenant ID,...
Definition client_certificate_credential.hpp:70
Core::Credentials::AccessToken GetToken(Core::Credentials::TokenRequestContext const &tokenRequestContext, Core::Context const &context) const override
Gets an authentication token.
Definition client_certificate_credential.cpp:471
~ClientCertificateCredential() override
Destructs ClientCertificateCredential.
Options for client certificate authentication.
Definition client_certificate_credential.hpp:44
std::vector< std::string > AdditionallyAllowedTenants
For multi-tenant applications, specifies additional tenants for which the credential may acquire toke...
Definition client_certificate_credential.hpp:62
std::string AuthorityHost
Authentication authority URL.
Definition client_certificate_credential.hpp:55
Token cache.