Skip to content

Commit

Permalink
OIDC connector option to override jwksURI
Browse files Browse the repository at this point in the history
Signed-off-by: sohgaura <tiwari.dk1@gmail.com>
  • Loading branch information
sohgaura committed May 21, 2024
1 parent 347beba commit f0651a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions connector/oidc/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ type ProviderDiscoveryOverrides struct {
// AuthURL provides a way to user overwrite the Auth URL
// from the .well-known/openid-configuration authorization_endpoint
AuthURL string `json:"authURL"`
// JWKSURL provides a way to user overwrite the JWKS URL
// from the .well-known/openid-configuration jwks_uri
JWKSURL string `json:"jwksURL"
}
func (o *ProviderDiscoveryOverrides) Empty() bool {
return o.TokenURL == "" && o.AuthURL == ""
return o.TokenURL == "" && o.AuthURL == "" && o.JWKSURL == ""
}
func getProvider(ctx context.Context, issuer string, overrides ProviderDiscoveryOverrides) (*oidc.Provider, error) {
Expand Down Expand Up @@ -151,7 +154,9 @@ func getProvider(ctx context.Context, issuer string, overrides ProviderDiscovery
if overrides.AuthURL != "" {
config.AuthURL = overrides.AuthURL
}

if overrides.JWKSURL != "" {
config.JWKSURL = overrides.JWKSURL
}
return config.NewProvider(context.Background()), nil
}
Expand Down
7 changes: 6 additions & 1 deletion connector/oidc/oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ func TestProviderOverride(t *testing.T) {
conn, err := newConnector(Config{
Issuer: testServer.URL,
Scopes: []string{"openid", "groups"},
ProviderDiscoveryOverrides: ProviderDiscoveryOverrides{TokenURL: "/test1", AuthURL: "/test2"},
ProviderDiscoveryOverrides: ProviderDiscoveryOverrides{TokenURL: "/test1", AuthURL: "/test2", JWKSURL:"/test3"},
})
if err != nil {
t.Fatal("failed to create new connector", err)
Expand All @@ -667,6 +667,11 @@ func TestProviderOverride(t *testing.T) {
if conn.provider.Endpoint().TokenURL != expToken {
t.Fatalf("unexpected token URL: %s, expected: %s\n", conn.provider.Endpoint().TokenURL, expToken)
}

expJWKS := "/test3"
if conn.provider.Endpoint().JWKSURL != expJWKS {
t.Fatalf("unexpected JWKS URL: %s, expected: %s\n", conn.provider.Endpoint().JWKSURL, expJWKS)
}
})
}

Expand Down

0 comments on commit f0651a9

Please sign in to comment.