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 AadGlobalAuthority =
"https://login.microsoftonline.com/";
22 class DefaultOptionValues final {
23 DefaultOptionValues() =
delete;
24 ~DefaultOptionValues() =
delete;
27 static std::string GetAuthorityHost()
29 const std::string envAuthHost
30 = Core::_internal::Environment::GetVariable(AzureAuthorityHostEnvVarName);
32 return envAuthHost.empty() ? AadGlobalAuthority : envAuthHost;
35 static std::string GetTenantId()
37 return Core::_internal::Environment::GetVariable(AzureTenantIdEnvVarName);
40 static std::string GetClientId()
42 return Core::_internal::Environment::GetVariable(AzureClientIdEnvVarName);
45 static std::string GetFederatedTokenFile()
47 return Core::_internal::Environment::GetVariable(AzureFederatedTokenFileEnvVarName);
51 class ClientCredentialCore final {
52 std::vector<std::string> m_additionallyAllowedTenants;
53 Core::Url m_authorityHost;
54 std::string m_tenantId;
57 explicit ClientCredentialCore(
59 std::string
const& authorityHost,
60 std::vector<std::string> additionallyAllowedTenants);
62 Core::Url GetRequestUrl(std::string
const& tenantId)
const;
64 std::string GetScopesString(
65 std::string
const& tenantId,
66 decltype(Core::Credentials::TokenRequestContext::Scopes)
const& scopes)
const;
68 std::string
const& GetTenantId()
const {
return m_tenantId; }
70 std::vector<std::string>
const& GetAdditionallyAllowedTenants()
const
72 return m_additionallyAllowedTenants;