diff --git a/go.mod b/go.mod index 4a3f12aee..0a3d35763 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.7.2 // indirect github.com/BurntSushi/toml v1.6.0 // indirect github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect diff --git a/go.sum b/go.sum index 4c7686d43..3727100ae 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEK github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 h1:XRzhVemXdgvJqCH0sFfrBUTnUJSBrBf7++ypk+twtRs= -github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.7.2 h1:RHK7bS+HQMslb1sZpAokUt+zTVmue0hKSs2C791hhzU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.7.2/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk= github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= diff --git a/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential/confidential.go b/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential/confidential.go index 29c004320..1b3e599b1 100644 --- a/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential/confidential.go +++ b/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential/confidential.go @@ -359,7 +359,7 @@ func New(authority, clientID string, cred Credential, options ...Option) (Client // authCodeURLOptions contains options for AuthCodeURL type authCodeURLOptions struct { - claims, loginHint, tenantID, domainHint string + claims, loginHint, tenantID, domainHint, prompt string } // AuthCodeURLOption is implemented by options for AuthCodeURL @@ -369,7 +369,7 @@ type AuthCodeURLOption interface { // AuthCodeURL creates a URL used to acquire an authorization code. Users need to call CreateAuthorizationCodeURLParameters and pass it in. // -// Options: [WithClaims], [WithDomainHint], [WithLoginHint], [WithTenantID] +// Options: [WithClaims], [WithDomainHint], [WithLoginHint], [WithTenantID], [WithPrompt] func (cca Client) AuthCodeURL(ctx context.Context, clientID, redirectURI string, scopes []string, opts ...AuthCodeURLOption) (string, error) { o := authCodeURLOptions{} if err := options.ApplyOptions(&o, opts); err != nil { @@ -382,6 +382,7 @@ func (cca Client) AuthCodeURL(ctx context.Context, clientID, redirectURI string, ap.Claims = o.claims ap.LoginHint = o.loginHint ap.DomainHint = o.domainHint + ap.Prompt = o.prompt return cca.base.AuthCodeURL(ctx, clientID, redirectURI, scopes, ap) } @@ -431,6 +432,29 @@ func WithDomainHint(domain string) interface { } } +// WithPrompt adds prompt query parameter in the auth url. +func WithPrompt(prompt shared.Prompt) interface { + AuthCodeURLOption + options.CallOption +} { + return struct { + AuthCodeURLOption + options.CallOption + }{ + CallOption: options.NewCallOption( + func(a any) error { + switch t := a.(type) { + case *authCodeURLOptions: + t.prompt = prompt.String() + default: + return fmt.Errorf("unexpected options type %T", a) + } + return nil + }, + ), + } +} + // WithClaims sets additional claims to request for the token, such as those required by conditional access policies. // Use this option when Azure AD returned a claims challenge for a prior request. The argument must be decoded. // This option is valid for any token acquisition method. diff --git a/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/base.go b/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/base.go index abf54f7e5..9bd96090e 100644 --- a/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/base.go +++ b/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/base.go @@ -302,13 +302,10 @@ func (b Client) AuthCodeURL(ctx context.Context, clientID, redirectURI string, s if authParams.DomainHint != "" { v.Add("domain_hint", authParams.DomainHint) } - // There were left over from an implementation that didn't use any of these. We may - // need to add them later, but as of now aren't needed. - /* - if p.ResponseMode != "" { - urlParams.Add("response_mode", p.ResponseMode) - } - */ + // Use form_post response mode for interactive auth to avoid exposing the auth code in the URL + if authParams.AuthorizationType == authority.ATInteractive { + v.Add("response_mode", "form_post") + } baseURL.RawQuery = v.Encode() return baseURL.String(), nil } diff --git a/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/storage/partitioned_storage.go b/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/storage/partitioned_storage.go index ff07d4b5a..5d018e117 100644 --- a/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/storage/partitioned_storage.go +++ b/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/storage/partitioned_storage.go @@ -200,7 +200,16 @@ func (m *PartitionedManager) aadMetadataFromCache(ctx context.Context, authority func (m *PartitionedManager) aadMetadata(ctx context.Context, authorityInfo authority.Info) (authority.InstanceDiscoveryMetadata, error) { discoveryResponse, err := m.requests.AADInstanceDiscovery(ctx, authorityInfo) if err != nil { - return authority.InstanceDiscoveryMetadata{}, err + // If it's an invalid_instance error, always propagate + if strings.Contains(err.Error(), "invalid_instance") { + return authority.InstanceDiscoveryMetadata{}, err + } + // If the caller canceled the context, propagate + if ctx.Err() != nil { + return authority.InstanceDiscoveryMetadata{}, err + } + // For transient errors (network failures, HTTP 500, etc.), cache a fallback entry + return m.fallbackMetadata(authorityInfo.Host), nil } m.aadCacheMu.Lock() @@ -220,6 +229,27 @@ func (m *PartitionedManager) aadMetadata(ctx context.Context, authorityInfo auth return m.aadCache[authorityInfo.Host], nil } +// fallbackMetadata returns a cached fallback metadata entry for the given host. +// It first checks the known metadata provider for pre-baked alias data, then +// falls back to a self-entry. Acquires aadCacheMu. +func (m *PartitionedManager) fallbackMetadata(host string) authority.InstanceDiscoveryMetadata { + m.aadCacheMu.Lock() + defer m.aadCacheMu.Unlock() + if known, ok := authority.GetKnownMetadata(host); ok { + for _, alias := range known.Aliases { + m.aadCache[alias] = known + } + return known + } + fallback := authority.InstanceDiscoveryMetadata{ + PreferredNetwork: host, + PreferredCache: host, + Aliases: []string{host}, + } + m.aadCache[host] = fallback + return fallback +} + func (m *PartitionedManager) readAccessToken(envAliases []string, realm, clientID, userAssertionHash string, scopes []string, partitionKey, tokenType, authnSchemeKeyID string) (AccessToken, error) { m.contractMu.RLock() defer m.contractMu.RUnlock() @@ -306,7 +336,7 @@ func (m *PartitionedManager) writeRefreshToken(refreshToken accesstokens.Refresh m.contractMu.Lock() defer m.contractMu.Unlock() key := refreshToken.Key() - if m.contract.AccessTokensPartition[partitionKey] == nil { + if m.contract.RefreshTokensPartition[partitionKey] == nil { m.contract.RefreshTokensPartition[partitionKey] = make(map[string]accesstokens.RefreshToken) } m.contract.RefreshTokensPartition[partitionKey][key] = refreshToken diff --git a/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/storage/storage.go b/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/storage/storage.go index 825d8a0f6..8225e860a 100644 --- a/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/storage/storage.go +++ b/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base/storage/storage.go @@ -276,7 +276,16 @@ func (m *Manager) aadMetadata(ctx context.Context, authorityInfo authority.Info) defer m.aadCacheMu.Unlock() discoveryResponse, err := m.requests.AADInstanceDiscovery(ctx, authorityInfo) if err != nil { - return authority.InstanceDiscoveryMetadata{}, err + // If it's an invalid_instance error, always propagate + if strings.Contains(err.Error(), "invalid_instance") { + return authority.InstanceDiscoveryMetadata{}, err + } + // If the caller canceled the context, propagate + if ctx.Err() != nil { + return authority.InstanceDiscoveryMetadata{}, err + } + // For transient errors (network failures, HTTP 500, etc.), cache a fallback entry + return m.fallbackMetadata(authorityInfo.Host), nil } for _, metadataEntry := range discoveryResponse.Metadata { @@ -293,6 +302,25 @@ func (m *Manager) aadMetadata(ctx context.Context, authorityInfo authority.Info) return m.aadCache[authorityInfo.Host], nil } +// fallbackMetadata returns a cached fallback metadata entry for the given host. +// It first checks the known metadata provider for pre-baked alias data, then +// falls back to a self-entry. The caller must hold m.aadCacheMu. +func (m *Manager) fallbackMetadata(host string) authority.InstanceDiscoveryMetadata { + if known, ok := authority.GetKnownMetadata(host); ok { + for _, alias := range known.Aliases { + m.aadCache[alias] = known + } + return known + } + fallback := authority.InstanceDiscoveryMetadata{ + PreferredNetwork: host, + PreferredCache: host, + Aliases: []string{host}, + } + m.aadCache[host] = fallback + return fallback +} + func (m *Manager) readAccessToken(homeID string, envAliases []string, realm, clientID string, scopes []string, tokenType, authnSchemeKeyID, extCacheKey string) AccessToken { m.contractMu.RLock() diff --git a/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/local/server.go b/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/local/server.go index c6baf2094..1fb012fea 100644 --- a/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/local/server.go +++ b/vendor/github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/local/server.go @@ -24,6 +24,7 @@ var okPage = []byte(`
Authentication complete. You can return to the application. Feel free to close this browser tab.
+For your security: Do not share the contents of this page, the address bar, or take screenshots.