Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow self-signed Root CA for SSO. Fixes #6793 #6961

Merged
merged 2 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions server/auth/sso/sso.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"fmt"
"net/http"
Expand Down Expand Up @@ -75,6 +76,7 @@ type Config struct {
// customGroupClaimName will override the groups claim name
CustomGroupClaimName string `json:"customGroupClaimName,omitempty"`
UserInfoPath string `json:"userInfoPath,omitempty"`
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
}

func (c Config) GetSessionExpiry() time.Duration {
Expand All @@ -93,10 +95,12 @@ type providerInterface interface {
Verifier(config *oidc.Config) *oidc.IDTokenVerifier
}

type providerFactory func(ctx context.Context, issuer string) (providerInterface, error)
type providerFactory func(ctx context.Context, issuer string, tlsConfig *tls.Config) (providerInterface, error)

func providerFactoryOIDC(ctx context.Context, issuer string) (providerInterface, error) {
return oidc.NewProvider(ctx, issuer)
func providerFactoryOIDC(ctx context.Context, issuer string, tlsConfig *tls.Config) (providerInterface, error) {
httpClient := &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}
oidcContext := oidc.ClientContext(ctx, httpClient)
return oidc.NewProvider(oidcContext, issuer)
}

func New(c Config, secretsIf corev1.SecretInterface, baseHRef string, secure bool) (Interface, error) {
Expand Down Expand Up @@ -131,7 +135,7 @@ func newSso(
providerCtx = oidc.InsecureIssuerURLContext(ctx, c.IssuerAlias)
}

provider, err := factory(providerCtx, c.Issuer)
provider, err := factory(providerCtx, c.Issuer, &tls.Config{InsecureSkipVerify: c.InsecureSkipVerify})
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -188,7 +192,7 @@ func newSso(
if err != nil {
return nil, fmt.Errorf("failed to create JWT encrpytor: %w", err)
}
lf := log.Fields{"redirectUrl": config.RedirectURL, "issuer": c.Issuer, "issuerAlias": "DISABLED", "clientId": c.ClientID, "scopes": config.Scopes}
lf := log.Fields{"redirectUrl": config.RedirectURL, "issuer": c.Issuer, "issuerAlias": "DISABLED", "clientId": c.ClientID, "scopes": config.Scopes, "insecureSkipVerify": c.InsecureSkipVerify}
if c.IssuerAlias != "" {
lf["issuerAlias"] = c.IssuerAlias
}
Expand Down
3 changes: 2 additions & 1 deletion server/auth/sso/sso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sso

import (
"context"
"crypto/tls"
"testing"
"time"

Expand All @@ -28,7 +29,7 @@ func (fakeOidcProvider) Verifier(config *oidc.Config) *oidc.IDTokenVerifier {
return nil
}

func fakeOidcFactory(ctx context.Context, issuer string) (providerInterface, error) {
func fakeOidcFactory(ctx context.Context, issuer string, tlsConfig *tls.Config) (providerInterface, error) {
return fakeOidcProvider{ctx, issuer}, nil
}

Expand Down