azure-identity
Loading...
Searching...
No Matches
azure_pipelines_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#include <azure/core/internal/http/pipeline.hpp>
17
18#include <string>
19#include <vector>
20
21namespace Azure { namespace Identity {
22 namespace _detail {
23 class TokenCredentialImpl;
24 } // namespace _detail
25
30 struct AzurePipelinesCredentialOptions final : public Core::Credentials::TokenCredentialOptions
31 {
42 std::string AuthorityHost = _detail::DefaultOptionValues::GetAuthorityHost();
43
49 std::vector<std::string> AdditionallyAllowedTenants;
50 };
51
56 class AzurePipelinesCredential final : public Core::Credentials::TokenCredential {
57 private:
58 std::string m_serviceConnectionId;
59 std::string m_systemAccessToken;
60 _detail::ClientCredentialCore m_clientCredentialCore;
61 Azure::Core::Http::_internal::HttpPipeline m_httpPipeline;
62 std::string m_oidcRequestUrl;
63 std::unique_ptr<_detail::TokenCredentialImpl> m_tokenCredentialImpl;
64 std::string m_requestBody;
65 _detail::TokenCache m_tokenCache;
66
67 std::string GetAssertion(Core::Context const& context) const;
68 Azure::Core::Http::Request CreateOidcRequestMessage() const;
69 std::string GetOidcTokenResponse(
70 std::unique_ptr<Azure::Core::Http::RawResponse> const& response,
71 std::string responseBody) const;
72
73 public:
87 std::string tenantId,
88 std::string clientId,
89 std::string serviceConnectionId,
90 std::string systemAccessToken,
91 AzurePipelinesCredentialOptions const& options = {});
92
98
107 Core::Credentials::AccessToken GetToken(
108 Core::Credentials::TokenRequestContext const& tokenRequestContext,
109 Core::Context const& context) const override;
110 };
111
112}} // namespace Azure::Identity
Credential which authenticates using an Azure Pipelines service connection.
Definition azure_pipelines_credential.hpp:56
Core::Credentials::AccessToken GetToken(Core::Credentials::TokenRequestContext const &tokenRequestContext, Core::Context const &context) const override
Gets an authentication token.
Definition azure_pipelines_credential.cpp:213
~AzurePipelinesCredential() override
Destructs AzurePipelinesCredential.
Options for Azure Pipelines credential.
Definition azure_pipelines_credential.hpp:31
std::string AuthorityHost
Authentication authority URL.
Definition azure_pipelines_credential.hpp:42
std::vector< std::string > AdditionallyAllowedTenants
For multi-tenant applications, specifies additional tenants for which the credential may acquire toke...
Definition azure_pipelines_credential.hpp:49
Token cache.