Debian Codegraph @

apps/internal/oauth/ops/authority/authority.go

raw symbols SCIP
1 // Copyright (c) Microsoft Corporation.
2 // Licensed under the MIT license.
3
4 package authorityscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/
5
6 import (
7 "contextscip-go gomod github.com/golang/go/src go1.18 context/"
8 "crypto/sha256scip-go gomod github.com/golang/go/src go1.18 `crypto/sha256`/"
9 "encoding/base64scip-go gomod github.com/golang/go/src go1.18 `encoding/base64`/"
10 "encoding/jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/"
11 "errorsscip-go gomod github.com/golang/go/src go1.18 errors/"
12 "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/"
13 "ioscip-go gomod github.com/golang/go/src go1.18 io/"
14 "net/httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/"
15 "net/urlscip-go gomod github.com/golang/go/src go1.18 `net/url`/"
16 "osscip-go gomod github.com/golang/go/src go1.18 os/"
17 "pathscip-go gomod github.com/golang/go/src go1.18 path/"
18 "stringsscip-go gomod github.com/golang/go/src go1.18 strings/"
19 "timescip-go gomod github.com/golang/go/src go1.18 time/"
20
21 "github.com/google/uuidscip-go gomod github.com/google/uuid v1.3.0 `github.com/google/uuid`/"
22 )
23
24 const (
25 authorizationEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/authorizationEndpoint. = "https://%v/%v/oauth2/v2.0/authorize"
26 instanceDiscoveryEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/instanceDiscoveryEndpoint. = "https://%v/common/discovery/instance"
27 tenantDiscoveryEndpointWithRegionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/tenantDiscoveryEndpointWithRegion. = "https://%s.%s/%s/v2.0/.well-known/openid-configuration"
28 regionNamescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/regionName. = "REGION_NAME"
29 defaultAPIVersionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/defaultAPIVersion. = "2021-10-01"
30 imdsEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/imdsEndpoint. = "http://169.254.169.254/metadata/instance/compute/location?format=text&api-version=" + defaultAPIVersionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/defaultAPIVersion.
31 autoDetectRegionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/autoDetectRegion. = "TryAutoDetect"
32 )
33
34 // These are various hosts that host AAD Instance discovery endpoints.
35 const (
36 defaultHostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/defaultHost. = "login.microsoftonline.com"
37 loginMicrosoftscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/loginMicrosoft. = "login.microsoft.com"
38 loginWindowsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/loginWindows. = "login.windows.net"
39 loginSTSWindowsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/loginSTSWindows. = "sts.windows.net"
40 loginMicrosoftOnlinescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/loginMicrosoftOnline. = defaultHostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/defaultHost.
41 )
42
43 // jsonCaller is an interface that allows us to mock the JSONCall method.
44 type jsonCallerscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/jsonCaller# interface {
45 JSONCallscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/jsonCaller#JSONCall.(ctx contextscip-go gomod github.com/golang/go/src go1.18 context/.Contextscip-go gomod github.com/golang/go/src go1.18 context/Context#, endpoint string, headers httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#, qv urlscip-go gomod github.com/golang/go/src go1.18 `net/url`/.Valuesscip-go gomod github.com/golang/go/src go1.18 `net/url`/Values#, body, resp interface{}) error
46 }
47
48 var aadTrustedHostListscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/aadTrustedHostList. = map[string]bool{
49 "login.windows.net": true, // Microsoft Azure Worldwide - Used in validation scenarios where host is not this list
50 "login.chinacloudapi.cn": true, // Microsoft Azure China
51 "login.microsoftonline.de": true, // Microsoft Azure Blackforest
52 "login-us.microsoftonline.com": true, // Microsoft Azure US Government - Legacy
53 "login.microsoftonline.us": true, // Microsoft Azure US Government
54 "login.microsoftonline.com": true, // Microsoft Azure Worldwide
55 "login.cloudgovapi.us": true, // Microsoft Azure US Government
56 }
57
58 // TrustedHost checks if an AAD host is trusted/valid.
59 func TrustedHostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TrustedHost().(host string) bool {
60 if _, ok := aadTrustedHostListscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/aadTrustedHostList.[host]; ok {
61 return true
62 }
63 return false
64 }
65
66 // OAuthResponseBase is the base JSON return message for an OAuth call.
67 // This is embedded in other calls to get the base fields from every response.
68 type OAuthResponseBasescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/OAuthResponseBase# struct {
69 Errorscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/OAuthResponseBase#Error. string `json:"error"`
70 SubErrorscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/OAuthResponseBase#SubError. string `json:"suberror"`
71 ErrorDescriptionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/OAuthResponseBase#ErrorDescription. string `json:"error_description"`
72 ErrorCodesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/OAuthResponseBase#ErrorCodes. []int `json:"error_codes"`
73 CorrelationIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/OAuthResponseBase#CorrelationID. string `json:"correlation_id"`
74 Claimsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/OAuthResponseBase#Claims. string `json:"claims"`
75 }
76
77 // TenantDiscoveryResponse is the tenant endpoints from the OpenID configuration endpoint.
78 type TenantDiscoveryResponsescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse# struct {
79 OAuthResponseBasescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#OAuthResponseBase.
80
81 AuthorizationEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#AuthorizationEndpoint. string `json:"authorization_endpoint"`
82 TokenEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#TokenEndpoint. string `json:"token_endpoint"`
83 Issuerscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#Issuer. string `json:"issuer"`
84
85 AdditionalFieldsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#AdditionalFields. map[string]interface{}
86 }
87
88 // Validate validates that the response had the correct values required.
89 func (r *TenantDiscoveryResponsescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#) Validatescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#Validate().() error {
90 switch "" {
91 case r.AuthorizationEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#AuthorizationEndpoint.:
92 return errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("TenantDiscoveryResponse: authorize endpoint was not found in the openid configuration")
93 case r.TokenEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#TokenEndpoint.:
94 return errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("TenantDiscoveryResponse: token endpoint was not found in the openid configuration")
95 case r.Issuerscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#Issuer.:
96 return errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("TenantDiscoveryResponse: issuer was not found in the openid configuration")
97 }
98 return nil
99 }
100
101 type InstanceDiscoveryMetadatascip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryMetadata# struct {
102 PreferredNetworkscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryMetadata#PreferredNetwork. string `json:"preferred_network"`
103 PreferredCachescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryMetadata#PreferredCache. string `json:"preferred_cache"`
104 Aliasesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryMetadata#Aliases. []string `json:"aliases"`
105
106 AdditionalFieldsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryMetadata#AdditionalFields. map[string]interface{}
107 }
108
109 type InstanceDiscoveryResponsescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryResponse# struct {
110 TenantDiscoveryEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryResponse#TenantDiscoveryEndpoint. string `json:"tenant_discovery_endpoint"`
111 Metadatascip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryResponse#Metadata. []InstanceDiscoveryMetadatascip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryMetadata# `json:"metadata"`
112
113 AdditionalFieldsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryResponse#AdditionalFields. map[string]interface{}
114 }
115
116 //go:generate stringer -type=AuthorizeType
117
118 // AuthorizeType represents the type of token flow.
119 type AuthorizeTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthorizeType# int
120
121 // These are all the types of token flows.
122 const (
123 ATUnknownscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATUnknown. AuthorizeTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthorizeType# = iota
124 ATUsernamePasswordscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATUsernamePassword.
125 ATWindowsIntegratedscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATWindowsIntegrated.
126 ATAuthCodescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATAuthCode.
127 ATInteractivescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATInteractive.
128 ATClientCredentialsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATClientCredentials.
129 ATDeviceCodescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATDeviceCode.
130 ATRefreshTokenscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATRefreshToken.
131 AccountByIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AccountByID.
132 ATOnBehalfOfscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATOnBehalfOf.
133 )
134
135 // These are all authority types
136 const (
137 AADscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AAD. = "MSSTS"
138 ADFSscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ADFS. = "ADFS"
139 )
140
141 // AuthParams represents the parameters used for authorization for token acquisition.
142 type AuthParamsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams# struct {
143 AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo. Infoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#
144 CorrelationIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#CorrelationID. string
145 Endpointsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Endpoints. Endpointsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Endpoints#
146 ClientIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#ClientID. string
147 // Redirecturi is used for auth flows that specify a redirect URI (e.g. local server for interactive auth flow).
148 Redirecturiscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Redirecturi. string
149 HomeAccountIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#HomeAccountID. string
150 // Username is the user-name portion for username/password auth flow.
151 Usernamescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Username. string
152 // Password is the password portion for username/password auth flow.
153 Passwordscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Password. string
154 // Scopes is the list of scopes the user consents to.
155 Scopesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Scopes. []string
156 // AuthorizationType specifies the auth flow being used.
157 AuthorizationTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorizationType. AuthorizeTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthorizeType#
158 // State is a random value used to prevent cross-site request forgery attacks.
159 Statescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#State. string
160 // CodeChallenge is derived from a code verifier and is sent in the auth request.
161 CodeChallengescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#CodeChallenge. string
162 // CodeChallengeMethod describes the method used to create the CodeChallenge.
163 CodeChallengeMethodscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#CodeChallengeMethod. string
164 // Prompt specifies the user prompt type during interactive auth.
165 Promptscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Prompt. string
166 // IsConfidentialClient specifies if it is a confidential client.
167 IsConfidentialClientscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#IsConfidentialClient. bool
168 // SendX5C specifies if x5c claim(public key of the certificate) should be sent to STS.
169 SendX5Cscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#SendX5C. bool
170 // UserAssertion is the access token used to acquire token on behalf of user
171 UserAssertionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#UserAssertion. string
172 // Capabilities the client will include with each token request, for example "CP1".
173 // Call [NewClientCapabilities] to construct a value for this field.
174 Capabilitiesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Capabilities. ClientCapabilitiesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities#
175 // Claims required for an access token to satisfy a conditional access policy
176 Claimsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Claims. string
177 // KnownAuthorityHosts don't require metadata discovery because they're known to the user
178 KnownAuthorityHostsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#KnownAuthorityHosts. []string
179 // LoginHint is a username with which to pre-populate account selection during interactive auth
180 LoginHintscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#LoginHint. string
181 // DomainHint is a directive that can be used to accelerate the user to their federated IdP sign-in page
182 DomainHintscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#DomainHint. string
183 }
184
185 // NewAuthParams creates an authorization parameters object.
186 func NewAuthParamsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/NewAuthParams().(clientID string, authorityInfo Infoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#) AuthParamsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams# {
187 return AuthParamsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#{
188 ClientIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#ClientID.: clientID,
189 AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo.: authorityInfo,
190 CorrelationIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#CorrelationID.: uuidscip-go gomod github.com/google/uuid v1.3.0 `github.com/google/uuid`/.Newscip-go gomod github.com/google/uuid v1.3.0 `github.com/google/uuid`/New().().Stringscip-go gomod github.com/google/uuid v1.3.0 `github.com/google/uuid`/UUID#String().(),
191 }
192 }
193
194 // WithTenant returns a copy of the AuthParams having the specified tenant ID. If the given
195 // ID is empty, the copy is identical to the original. This function returns an error in
196 // several cases:
197 // - ID isn't specific (for example, it's "common")
198 // - ID is non-empty and the authority doesn't support tenants (for example, it's an ADFS authority)
199 // - the client is configured to authenticate only Microsoft accounts via the "consumers" endpoint
200 // - the resulting authority URL is invalid
201 func (p AuthParamsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#) WithTenantscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#WithTenant().(ID string) (AuthParamsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#, error) {
202 switch ID {
203 case "", p.AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo..Tenantscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Tenant.:
204 // keep the default tenant because the caller didn't override it
205 return p, nil
206 case "common", "consumers", "organizations":
207 if p.AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo..AuthorityTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#AuthorityType. == AADscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AAD. {
208 return p, fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().(`tenant ID must be a specific tenant, not "%s"`, ID)
209 }
210 // else we'll return a better error below
211 }
212 if p.AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo..AuthorityTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#AuthorityType. != AADscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AAD. {
213 return p, errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("the authority doesn't support tenants")
214 }
215 if p.AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo..Tenantscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Tenant. == "consumers" {
216 return p, errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().(`client is configured to authenticate only personal Microsoft accounts, via the "consumers" endpoint`)
217 }
218 authority := "https://" + pathscip-go gomod github.com/golang/go/src go1.18 path/.Joinscip-go gomod github.com/golang/go/src go1.18 path/Join().(p.AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo..Hostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Host., ID)
219 info, err := NewInfoFromAuthorityURIscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/NewInfoFromAuthorityURI().(authority, p.AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo..ValidateAuthorityscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#ValidateAuthority., p.AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo..InstanceDiscoveryDisabledscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#InstanceDiscoveryDisabled.)
220 if err == nil {
221 info.Regionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Region. = p.AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo..Regionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Region.
222 p.AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo. = info
223 }
224 return p, err
225 }
226
227 // MergeCapabilitiesAndClaims combines client capabilities and challenge claims into a value suitable for an authentication request's "claims" parameter.
228 func (p AuthParamsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#) MergeCapabilitiesAndClaimsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#MergeCapabilitiesAndClaims().() (string, error) {
229 claims := p.Claimsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Claims.
230 if len(p.Capabilitiesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Capabilities..asMapscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities#asMap.) > 0 {
231 if claims == "" {
232 // without claims the result is simply the capabilities
233 return p.Capabilitiesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Capabilities..asJSONscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities#asJSON., nil
234 }
235 // Otherwise, merge claims and capabilties into a single JSON object.
236 // We handle the claims challenge as a map because we don't know its structure.
237 var challenge map[string]any
238 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().([]byte(claims), &challenge); err != nil {
239 return "", fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().(`claims must be JSON. Are they base64 encoded? json.Unmarshal returned "%v"`, err)
240 }
241 if err := mergescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/merge().(p.Capabilitiesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Capabilities..asMapscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities#asMap., challenge); err != nil {
242 return "", err
243 }
244 b, err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Marshal().(challenge)
245 if err != nil {
246 return "", err
247 }
248 claims = string(b)
249 }
250 return claims, nil
251 }
252
253 // merges a into b without overwriting b's values. Returns an error when a and b share a key for which either has a non-object value.
254 func mergescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/merge().(a, b map[string]any) error {
255 for k, av := range a {
256 if bv, ok := b[k]; !ok {
257 // b doesn't contain this key => simply set it to a's value
258 b[k] = av
259 } else {
260 // b does contain this key => recursively merge a[k] into b[k], provided both are maps. If a[k] or b[k] isn't
261 // a map, return an error because merging would overwrite some value in b. Errors shouldn't occur in practice
262 // because the challenge will be from AAD, which knows the capabilities format.
263 if A, ok := av.(map[string]any); ok {
264 if B, ok := bv.(map[string]any); ok {
265 return mergescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/merge().(A, B)
266 } else {
267 // b[k] isn't a map
268 return errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("challenge claims conflict with client capabilities")
269 }
270 } else {
271 // a[k] isn't a map
272 return errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("challenge claims conflict with client capabilities")
273 }
274 }
275 }
276 return nil
277 }
278
279 // ClientCapabilities stores capabilities in the formats used by AuthParams.MergeCapabilitiesAndClaims.
280 // [NewClientCapabilities] precomputes these representations because capabilities are static for the
281 // lifetime of a client and are included with every authentication request i.e., these computations
282 // always have the same result and would otherwise have to be repeated for every request.
283 type ClientCapabilitiesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities# struct {
284 // asJSON is for the common case: adding the capabilities to an auth request with no challenge claims
285 asJSONscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities#asJSON. string
286 // asMap is for merging the capabilities with challenge claims
287 asMapscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities#asMap. map[string]any
288 }
289
290 func NewClientCapabilitiesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/NewClientCapabilities().(capabilities []string) (ClientCapabilitiesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities#, error) {
291 c := ClientCapabilitiesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities#{}
292 var err error
293 if len(capabilities) > 0 {
294 cpbs := make([]string, len(capabilities))
295 for i := 0; i < len(cpbs); i++ {
296 cpbs[i] = fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().(`"%s"`, capabilities[i])
297 }
298 c.asJSONscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities#asJSON. = fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().(`{"access_token":{"xms_cc":{"values":[%s]}}}`, stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Joinscip-go gomod github.com/golang/go/src go1.18 strings/Join().(cpbs, ","))
299 // note our JSON is valid but we can't stop users breaking it with garbage like "}"
300 err = jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().([]byte(c.asJSONscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities#asJSON.), &c.asMapscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ClientCapabilities#asMap.)
301 }
302 return c, err
303 }
304
305 // Info consists of information about the authority.
306 type Infoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info# struct {
307 Hostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Host. string
308 CanonicalAuthorityURIscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#CanonicalAuthorityURI. string
309 AuthorityTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#AuthorityType. string
310 UserRealmURIPrefixscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#UserRealmURIPrefix. string
311 ValidateAuthorityscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#ValidateAuthority. bool
312 Tenantscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Tenant. string
313 Regionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Region. string
314 InstanceDiscoveryDisabledscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#InstanceDiscoveryDisabled. bool
315 }
316
317 func firstPathSegmentscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/firstPathSegment().(u *urlscip-go gomod github.com/golang/go/src go1.18 `net/url`/.URLscip-go gomod github.com/golang/go/src go1.18 `net/url`/URL#) (string, error) {
318 pathParts := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Splitscip-go gomod github.com/golang/go/src go1.18 strings/Split().(u.EscapedPathscip-go gomod github.com/golang/go/src go1.18 `net/url`/URL#EscapedPath().(), "/")
319 if len(pathParts) >= 2 {
320 return pathParts[1], nil
321 }
322
323 return "", errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().(`authority must be an https URL such as "https://login.microsoftonline.com/<your tenant>"`)
324 }
325
326 // NewInfoFromAuthorityURI creates an AuthorityInfo instance from the authority URL provided.
327 func NewInfoFromAuthorityURIscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/NewInfoFromAuthorityURI().(authority string, validateAuthority bool, instanceDiscoveryDisabled bool) (Infoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#, error) {
328 u, err := urlscip-go gomod github.com/golang/go/src go1.18 `net/url`/.Parsescip-go gomod github.com/golang/go/src go1.18 `net/url`/Parse().(stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.18 strings/ToLower().(authority))
329 if err != nil || u.Schemescip-go gomod github.com/golang/go/src go1.18 `net/url`/URL#Scheme. != "https" {
330 return Infoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#{}, errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().(`authority must be an https URL such as "https://login.microsoftonline.com/<your tenant>"`)
331 }
332
333 tenant, err := firstPathSegmentscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/firstPathSegment().(u)
334 if err != nil {
335 return Infoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#{}, err
336 }
337 authorityType := AADscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AAD.
338 if tenant == "adfs" {
339 authorityType = ADFSscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ADFS.
340 }
341
342 // u.Host includes the port, if any, which is required for private cloud deployments
343 return Infoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#{
344 Hostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Host.: u.Hostscip-go gomod github.com/golang/go/src go1.18 `net/url`/URL#Host.,
345 CanonicalAuthorityURIscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#CanonicalAuthorityURI.: fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("https://%v/%v/", u.Hostscip-go gomod github.com/golang/go/src go1.18 `net/url`/URL#Host., tenant),
346 AuthorityTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#AuthorityType.: authorityType,
347 UserRealmURIPrefixscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#UserRealmURIPrefix.: fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("https://%v/common/userrealm/", u.Hostnamescip-go gomod github.com/golang/go/src go1.18 `net/url`/URL#Hostname().()),
348 ValidateAuthorityscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#ValidateAuthority.: validateAuthority,
349 Tenantscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Tenant.: tenant,
350 InstanceDiscoveryDisabledscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#InstanceDiscoveryDisabled.: instanceDiscoveryDisabled,
351 }, nil
352 }
353
354 // Endpoints consists of the endpoints from the tenant discovery response.
355 type Endpointsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Endpoints# struct {
356 AuthorizationEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Endpoints#AuthorizationEndpoint. string
357 TokenEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Endpoints#TokenEndpoint. string
358 selfSignedJwtAudiencescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Endpoints#selfSignedJwtAudience. string
359 authorityHostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Endpoints#authorityHost. string
360 }
361
362 // NewEndpoints creates an Endpoints object.
363 func NewEndpointsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/NewEndpoints().(authorizationEndpoint string, tokenEndpoint string, selfSignedJwtAudience string, authorityHost string) Endpointsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Endpoints# {
364 return Endpointsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Endpoints#{authorizationEndpoint, tokenEndpoint, selfSignedJwtAudience, authorityHost}
365 }
366
367 // UserRealmAccountType refers to the type of user realm.
368 type UserRealmAccountTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealmAccountType# string
369
370 // These are the different types of user realms.
371 const (
372 Unknownscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Unknown. UserRealmAccountTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealmAccountType# = ""
373 Federatedscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Federated. UserRealmAccountTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealmAccountType# = "Federated"
374 Managedscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Managed. UserRealmAccountTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealmAccountType# = "Managed"
375 )
376
377 // UserRealm is used for the username password request to determine user type
378 type UserRealmscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm# struct {
379 AccountTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#AccountType. UserRealmAccountTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealmAccountType# `json:"account_type"`
380 DomainNamescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#DomainName. string `json:"domain_name"`
381 CloudInstanceNamescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#CloudInstanceName. string `json:"cloud_instance_name"`
382 CloudAudienceURNscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#CloudAudienceURN. string `json:"cloud_audience_urn"`
383
384 // required if accountType is Federated
385 FederationProtocolscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#FederationProtocol. string `json:"federation_protocol"`
386 FederationMetadataURLscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#FederationMetadataURL. string `json:"federation_metadata_url"`
387
388 AdditionalFieldsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#AdditionalFields. map[string]interface{}
389 }
390
391 func (u UserRealmscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#) validatescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#validate().() error {
392 switch "" {
393 case string(u.AccountTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#AccountType.):
394 return errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("the account type (Federated or Managed) is missing")
395 case u.DomainNamescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#DomainName.:
396 return errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("domain name of user realm is missing")
397 case u.CloudInstanceNamescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#CloudInstanceName.:
398 return errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("cloud instance name of user realm is missing")
399 case u.CloudAudienceURNscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#CloudAudienceURN.:
400 return errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("cloud Instance URN is missing")
401 }
402
403 if u.AccountTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#AccountType. == Federatedscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Federated. {
404 switch "" {
405 case u.FederationProtocolscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#FederationProtocol.:
406 return errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("federation protocol of user realm is missing")
407 case u.FederationMetadataURLscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#FederationMetadataURL.:
408 return errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("federation metadata URL of user realm is missing")
409 }
410 }
411 return nil
412 }
413
414 // Client represents the REST calls to authority backends.
415 type Clientscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Client# struct {
416 // Comm provides the HTTP transport client.
417 Commscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Client#Comm. jsonCallerscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/jsonCaller# // *comm.Client
418 }
419
420 func (c Clientscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Client#) UserRealmscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Client#UserRealm().(ctx contextscip-go gomod github.com/golang/go/src go1.18 context/.Contextscip-go gomod github.com/golang/go/src go1.18 context/Context#, authParams AuthParamsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#) (UserRealmscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#, error) {
421 endpoint := fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("https://%s/common/UserRealm/%s", authParams.Endpointsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Endpoints..authorityHostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Endpoints#authorityHost., urlscip-go gomod github.com/golang/go/src go1.18 `net/url`/.PathEscapescip-go gomod github.com/golang/go/src go1.18 `net/url`/PathEscape().(authParams.Usernamescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#Username.))
422 qv := urlscip-go gomod github.com/golang/go/src go1.18 `net/url`/.Valuesscip-go gomod github.com/golang/go/src go1.18 `net/url`/Values#{
423 "api-version": []string{"1.0"},
424 }
425
426 resp := UserRealmscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#{}
427 err := c.Commscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Client#Comm..JSONCallscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/jsonCaller#JSONCall.(
428 ctx,
429 endpoint,
430 httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{"client-request-id": []string{authParams.CorrelationIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#CorrelationID.}},
431 qv,
432 nil,
433 &resp,
434 )
435 if err != nil {
436 return resp, err
437 }
438
439 return resp, resp.validatescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/UserRealm#validate().()
440 }
441
442 func (c Clientscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Client#) GetTenantDiscoveryResponsescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Client#GetTenantDiscoveryResponse().(ctx contextscip-go gomod github.com/golang/go/src go1.18 context/.Contextscip-go gomod github.com/golang/go/src go1.18 context/Context#, openIDConfigurationEndpoint string) (TenantDiscoveryResponsescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#, error) {
443 resp := TenantDiscoveryResponsescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TenantDiscoveryResponse#{}
444 err := c.Commscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Client#Comm..JSONCallscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/jsonCaller#JSONCall.(
445 ctx,
446 openIDConfigurationEndpoint,
447 httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{},
448 nil,
449 nil,
450 &resp,
451 )
452
453 return resp, err
454 }
455
456 // AADInstanceDiscovery attempts to discover a tenant endpoint (used in OIDC auth with an authorization endpoint).
457 // This is done by AAD which allows for aliasing of tenants (windows.sts.net is the same as login.windows.com).
458 func (c Clientscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Client#) AADInstanceDiscoveryscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Client#AADInstanceDiscovery().(ctx contextscip-go gomod github.com/golang/go/src go1.18 context/.Contextscip-go gomod github.com/golang/go/src go1.18 context/Context#, authorityInfo Infoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#) (InstanceDiscoveryResponsescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryResponse#, error) {
459 region := ""
460 var err error
461 resp := InstanceDiscoveryResponsescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryResponse#{}
462 if authorityInfo.Regionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Region. != "" && authorityInfo.Regionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Region. != autoDetectRegionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/autoDetectRegion. {
463 region = authorityInfo.Regionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Region.
464 } else if authorityInfo.Regionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Region. == autoDetectRegionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/autoDetectRegion. {
465 region = detectRegionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/detectRegion().(ctx)
466 }
467 if region != "" {
468 environment := authorityInfo.Hostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Host.
469 switch environment {
470 case loginMicrosoftscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/loginMicrosoft., loginWindowsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/loginWindows., loginSTSWindowsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/loginSTSWindows., defaultHostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/defaultHost.:
471 environment = loginMicrosoftscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/loginMicrosoft.
472 }
473
474 resp.TenantDiscoveryEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryResponse#TenantDiscoveryEndpoint. = fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().(tenantDiscoveryEndpointWithRegionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/tenantDiscoveryEndpointWithRegion., region, environment, authorityInfo.Tenantscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Tenant.)
475 metadata := InstanceDiscoveryMetadatascip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryMetadata#{
476 PreferredNetworkscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryMetadata#PreferredNetwork.: fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%v.%v", region, authorityInfo.Hostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Host.),
477 PreferredCachescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryMetadata#PreferredCache.: authorityInfo.Hostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Host.,
478 Aliasesscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryMetadata#Aliases.: []string{fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%v.%v", region, authorityInfo.Hostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Host.), authorityInfo.Hostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Host.},
479 }
480 resp.Metadatascip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryResponse#Metadata. = []InstanceDiscoveryMetadatascip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/InstanceDiscoveryMetadata#{metadata}
481 } else {
482 qv := urlscip-go gomod github.com/golang/go/src go1.18 `net/url`/.Valuesscip-go gomod github.com/golang/go/src go1.18 `net/url`/Values#{}
483 qv.Setscip-go gomod github.com/golang/go/src go1.18 `net/url`/Values#Set().("api-version", "1.1")
484 qv.Setscip-go gomod github.com/golang/go/src go1.18 `net/url`/Values#Set().("authorization_endpoint", fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().(authorizationEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/authorizationEndpoint., authorityInfo.Hostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Host., authorityInfo.Tenantscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Tenant.))
485
486 discoveryHost := defaultHostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/defaultHost.
487 if TrustedHostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/TrustedHost().(authorityInfo.Hostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Host.) {
488 discoveryHost = authorityInfo.Hostscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Host.
489 }
490
491 endpoint := fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().(instanceDiscoveryEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/instanceDiscoveryEndpoint., discoveryHost)
492 err = c.Commscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Client#Comm..JSONCallscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/jsonCaller#JSONCall.(ctx, endpoint, httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{}, qv, nil, &resp)
493 }
494 return resp, err
495 }
496
497 func detectRegionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/detectRegion().(ctx contextscip-go gomod github.com/golang/go/src go1.18 context/.Contextscip-go gomod github.com/golang/go/src go1.18 context/Context#) string {
498 region := osscip-go gomod github.com/golang/go/src go1.18 os/.Getenvscip-go gomod github.com/golang/go/src go1.18 os/Getenv().(regionNamescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/regionName.)
499 if region != "" {
500 region = stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.18 strings/ReplaceAll().(region, " ", "")
501 return stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.18 strings/ToLower().(region)
502 }
503 // HTTP call to IMDS endpoint to get region
504 // Refer : https://identitydivision.visualstudio.com/DevEx/_git/AuthLibrariesApiReview?path=%2FPinAuthToRegion%2FAAD%20SDK%20Proposal%20to%20Pin%20Auth%20to%20region.md&_a=preview&version=GBdev
505 // Set a 2 second timeout for this http client which only does calls to IMDS endpoint
506 client := httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Clientscip-go gomod github.com/golang/go/src go1.18 `net/http`/Client#{
507 Timeoutscip-go gomod github.com/golang/go/src go1.18 `net/http`/Client#Timeout.: timescip-go gomod github.com/golang/go/src go1.18 time/.Durationscip-go gomod github.com/golang/go/src go1.18 time/Duration#(2 * timescip-go gomod github.com/golang/go/src go1.18 time/.Secondscip-go gomod github.com/golang/go/src go1.18 time/Second.),
508 }
509 req, _ := httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.NewRequestscip-go gomod github.com/golang/go/src go1.18 `net/http`/NewRequest().("GET", imdsEndpointscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/imdsEndpoint., nil)
510 req.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Request#Header..Setscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#Set().("Metadata", "true")
511 resp, err := client.Doscip-go gomod github.com/golang/go/src go1.18 `net/http`/Client#Do().(req)
512 // If the request times out or there is an error, it is retried once
513 if err != nil || resp.StatusCodescip-go gomod github.com/golang/go/src go1.18 `net/http`/Response#StatusCode. != 200 {
514 resp, err = client.Doscip-go gomod github.com/golang/go/src go1.18 `net/http`/Client#Do().(req)
515 if err != nil || resp.StatusCodescip-go gomod github.com/golang/go/src go1.18 `net/http`/Response#StatusCode. != 200 {
516 return ""
517 }
518 }
519 defer resp.Bodyscip-go gomod github.com/golang/go/src go1.18 `net/http`/Response#Body..Closescip-go gomod github.com/golang/go/src go1.18 io/Closer#Close().()
520 response, err := ioscip-go gomod github.com/golang/go/src go1.18 io/.ReadAllscip-go gomod github.com/golang/go/src go1.18 io/ReadAll().(resp.Bodyscip-go gomod github.com/golang/go/src go1.18 `net/http`/Response#Body.)
521 if err != nil {
522 return ""
523 }
524 return string(response)
525 }
526
527 func (a *AuthParamsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#) CacheKeyscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#CacheKey().(isAppCache bool) string {
528 if a.AuthorizationTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorizationType. == ATOnBehalfOfscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATOnBehalfOf. {
529 return a.AssertionHashscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AssertionHash().()
530 }
531 if a.AuthorizationTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorizationType. == ATClientCredentialsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATClientCredentials. || isAppCache {
532 return a.AppKeyscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AppKey().()
533 }
534 if a.AuthorizationTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorizationType. == ATRefreshTokenscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/ATRefreshToken. || a.AuthorizationTypescip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorizationType. == AccountByIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AccountByID. {
535 return a.HomeAccountIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#HomeAccountID.
536 }
537 return ""
538 }
539 func (a *AuthParamsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#) AssertionHashscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AssertionHash().() string {
540 hasher := sha256scip-go gomod github.com/golang/go/src go1.18 `crypto/sha256`/.Newscip-go gomod github.com/golang/go/src go1.18 `crypto/sha256`/New().()
541 // Per documentation this never returns an error : https://pkg.go.dev/hash#pkg-types
542 _, _ = hasher.Writescip-go gomod github.com/golang/go/src go1.18 io/Writer#Write().([]byte(a.UserAssertionscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#UserAssertion.))
543 sha := base64scip-go gomod github.com/golang/go/src go1.18 `encoding/base64`/.URLEncodingscip-go gomod github.com/golang/go/src go1.18 `encoding/base64`/URLEncoding..EncodeToStringscip-go gomod github.com/golang/go/src go1.18 `encoding/base64`/Encoding#EncodeToString().(hasher.Sumscip-go gomod github.com/golang/go/src go1.18 hash/Hash#Sum().(nil))
544 return sha
545 }
546
547 func (a *AuthParamsscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#) AppKeyscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AppKey().() string {
548 if a.AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo..Tenantscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Tenant. != "" {
549 return fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%s_%s_AppTokenCache", a.ClientIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#ClientID., a.AuthorityInfoscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#AuthorityInfo..Tenantscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/Info#Tenant.)
550 }
551 return fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%s__AppTokenCache", a.ClientIDscip-go gomod github.com/AzureAD/microsoft-authentication-library-for-go . `github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority`/AuthParams#ClientID.)
552 }