6#include "azure/identity/dll_import_export.hpp"
8#include <azure/core/credentials/credentials.hpp>
9#include <azure/core/internal/environment.hpp>
10#include <azure/core/url.hpp>
15namespace Azure {
namespace Identity {
namespace _detail {
16 constexpr auto AzureAuthorityHostEnvVarName =
"AZURE_AUTHORITY_HOST";
17 constexpr auto AzureTenantIdEnvVarName =
"AZURE_TENANT_ID";
18 constexpr auto AzureClientIdEnvVarName =
"AZURE_CLIENT_ID";
19 constexpr auto AzureFederatedTokenFileEnvVarName =
"AZURE_FEDERATED_TOKEN_FILE";
20 const std::string OidcRequestUrlEnvVarName =
"SYSTEM_OIDCREQUESTURI";
21 const std::string AadGlobalAuthority =
"https://login.microsoftonline.com/";
23 class DefaultOptionValues final {
24 DefaultOptionValues() =
delete;
25 ~DefaultOptionValues() =
delete;
28 static std::string GetAuthorityHost()
30 const std::string envAuthHost
31 = Core::_internal::Environment::GetVariable(AzureAuthorityHostEnvVarName);
33 return envAuthHost.empty() ? AadGlobalAuthority : envAuthHost;
36 static std::string GetTenantId()
38 return Core::_internal::Environment::GetVariable(AzureTenantIdEnvVarName);
41 static std::string GetClientId()
43 return Core::_internal::Environment::GetVariable(AzureClientIdEnvVarName);
46 static std::string GetFederatedTokenFile()
48 return Core::_internal::Environment::GetVariable(AzureFederatedTokenFileEnvVarName);
51 static std::string GetOidcRequestUrl()
53 return Core::_internal::Environment::GetVariable(OidcRequestUrlEnvVarName.c_str());
57 class ClientCredentialCore final {
58 std::vector<std::string> m_additionallyAllowedTenants;
59 Core::Url m_authorityHost;
60 std::string m_tenantId;
63 explicit ClientCredentialCore(
65 std::string
const& authorityHost,
66 std::vector<std::string> additionallyAllowedTenants);
68 Core::Url GetRequestUrl(std::string
const& tenantId)
const;
70 std::string GetScopesString(
71 std::string
const& tenantId,
72 decltype(Core::Credentials::TokenRequestContext::Scopes)
const& scopes)
const;
74 std::string
const& GetTenantId()
const {
return m_tenantId; }
76 std::vector<std::string>
const& GetAdditionallyAllowedTenants()
const
78 return m_additionallyAllowedTenants;