Skip to content

Commit

Permalink
allow alternative issuer in NewProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico Muerdter authored and monstermunchkin committed Mar 4, 2025
1 parent 4b5f82d commit 1e856d5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions oidc/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (p *ProviderConfig) NewProvider(ctx context.Context) *Provider {
// should use [ProviderConfig] instead.
//
// See: https://openid.net/specs/openid-connect-discovery-1_0.html
func NewProvider(ctx context.Context, issuer string) (*Provider, error) {
func NewProvider(ctx context.Context, issuer string, alternativeIssuer ...string) (*Provider, error) {
wellKnown := strings.TrimSuffix(issuer, "/") + "/.well-known/openid-configuration"
req, err := http.NewRequest("GET", wellKnown, nil)
if err != nil {
Expand Down Expand Up @@ -266,8 +266,10 @@ func NewProvider(ctx context.Context, issuer string) (*Provider, error) {
if !skipIssuerValidation {
issuerURL = issuer
}
if p.Issuer != issuerURL && !skipIssuerValidation {
return nil, fmt.Errorf("oidc: issuer did not match the issuer returned by provider, expected %q got %q", issuer, p.Issuer)
alternativeIssuer = append(alternativeIssuer, issuer)
issuerStr := strings.Join(alternativeIssuer, " ")
if !strings.Contains(issuerStr, p.Issuer) {
return nil, fmt.Errorf("oidc: issuer did not match the issuer returned by provider, expected one of %q got %q", issuerStr, p.Issuer)
}
var algs []string
for _, a := range p.Algorithms {
Expand Down

0 comments on commit 1e856d5

Please sign in to comment.