Skip to content

Commit

Permalink
Merge pull request #342 from dimityrmirchev/default-oidc-root-ca
Browse files Browse the repository at this point in the history
OIDC authenticator defaults to using host's root CA pool if CA file is not provided
  • Loading branch information
stlaz authored Dec 9, 2024
2 parents 28ede67 + 06bdb53 commit 0b6ff42
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/authn/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ var (

// NewOIDCAuthenticator returns OIDC authenticator
func NewOIDCAuthenticator(ctx context.Context, config *OIDCConfig) (*OIDCAuthenticator, error) {
dyCA, err := dynamiccertificates.NewDynamicCAContentFromFile("oidc-ca", config.CAFile)
if err != nil {
return nil, err
var dynamicCA *dynamiccertificates.DynamicFileCAContent
if len(config.CAFile) > 0 { // if unset, the OIDC authenticator defaults to host's trust store
var err error
dynamicCA, err = dynamiccertificates.NewDynamicCAContentFromFile("oidc-ca", config.CAFile)
if err != nil {
return nil, err
}
}

tokenAuthenticator, err := oidc.New(ctx, oidc.Options{
Expand All @@ -60,15 +64,15 @@ func NewOIDCAuthenticator(ctx context.Context, config *OIDCConfig) (*OIDCAuthent
},
},
},
CAContentProvider: dyCA,
CAContentProvider: dynamicCA,
SupportedSigningAlgs: config.SupportedSigningAlgs,
})
if err != nil {
return nil, err
}

return &OIDCAuthenticator{
dynamicClientCA: dyCA,
dynamicClientCA: dynamicCA,
requestAuthenticator: bearertoken.New(tokenAuthenticator),
}, nil
}
Expand Down

0 comments on commit 0b6ff42

Please sign in to comment.