azure-identity
Loading...
Searching...
No Matches
client_assertion_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#include <azure/core/http/http.hpp>
16
17#include <string>
18#include <vector>
19
20namespace Azure { namespace Identity {
21 namespace _detail {
22 class TokenCredentialImpl;
23 } // namespace _detail
24
29 struct ClientAssertionCredentialOptions final : public Core::Credentials::TokenCredentialOptions
30 {
41 std::string AuthorityHost = _detail::DefaultOptionValues::GetAuthorityHost();
42
48 std::vector<std::string> AdditionallyAllowedTenants;
49 };
50
56 class ClientAssertionCredential final : public Core::Credentials::TokenCredential {
57 private:
58 std::function<std::string(Core::Context const&)> m_assertionCallback;
59 _detail::ClientCredentialCore m_clientCredentialCore;
60 std::unique_ptr<_detail::TokenCredentialImpl> m_tokenCredentialImpl;
61 std::string m_requestBody;
62 _detail::TokenCache m_tokenCache;
63
64 public:
77 std::string tenantId,
78 std::string clientId,
79 std::function<std::string(Core::Context const&)> assertionCallback,
80 ClientAssertionCredentialOptions const& options = {});
81
87
98 Core::Credentials::AccessToken GetToken(
99 Core::Credentials::TokenRequestContext const& tokenRequestContext,
100 Core::Context const& context) const override;
101 };
102
103}} // namespace Azure::Identity
Credential which authenticates a Microsoft Entra service principal using a signed client assertion.
Definition client_assertion_credential.hpp:56
Core::Credentials::AccessToken GetToken(Core::Credentials::TokenRequestContext const &tokenRequestContext, Core::Context const &context) const override
Obtains an authentication token from Microsoft Entra ID, by calling the assertionCallback specified w...
Definition client_assertion_credential.cpp:110
~ClientAssertionCredential() override
Destructs ClientAssertionCredential.
Options used to configure the Client Assertion credential.
Definition client_assertion_credential.hpp:30
std::vector< std::string > AdditionallyAllowedTenants
For multi-tenant applications, specifies additional tenants for which the credential may acquire toke...
Definition client_assertion_credential.hpp:48
std::string AuthorityHost
Authentication authority URL.
Definition client_assertion_credential.hpp:41
Token cache.