diff --git a/pkg/apiserver/authentication/identityprovider/oidc/oidc.go b/pkg/apiserver/authentication/identityprovider/oidc/oidc.go index cddb5f31a..efd821bb1 100644 --- a/pkg/apiserver/authentication/identityprovider/oidc/oidc.go +++ b/pkg/apiserver/authentication/identityprovider/oidc/oidc.go @@ -19,6 +19,7 @@ package oidc import ( "context" "crypto/tls" + "encoding/base64" "encoding/json" "errors" "fmt" @@ -115,7 +116,7 @@ type oidcIdentity struct { } func (o oidcIdentity) GetUserID() string { - return o.Sub + return base64.RawURLEncoding.EncodeToString([]byte(o.Sub)) } func (o oidcIdentity) GetUsername() string { diff --git a/pkg/apiserver/authentication/identityprovider/oidc/oidc_test.go b/pkg/apiserver/authentication/identityprovider/oidc/oidc_test.go index 5430e8924..e716672b0 100644 --- a/pkg/apiserver/authentication/identityprovider/oidc/oidc_test.go +++ b/pkg/apiserver/authentication/identityprovider/oidc/oidc_test.go @@ -198,7 +198,7 @@ var _ = Describe("OIDC", func() { req := &http.Request{URL: url} identity, err := provider.IdentityExchangeCallback(req) Expect(err).Should(BeNil()) - Expect(identity.GetUserID()).Should(Equal("110169484474386276334")) + Expect(identity.GetUserID()).Should(Equal(base64.RawURLEncoding.EncodeToString([]byte("110169484474386276334")))) Expect(identity.GetUsername()).Should(Equal("test")) Expect(identity.GetEmail()).Should(Equal("test@kubesphere.io")) })