[KS-OIDC] Remove special characters form sub OIDC standard claim (#5018)

* [KS-OIDC] Remove special characters form sub OIDC standard claim

* [KS-OIDC] Change to base64 RawURLEncoding

* [KS-OIDC] Import encoding/base64

* [KS-OIDC] Change import

* [KS-OIDC] Damn Go

* [KS-OIDC] Damn Spaces

* [KS-OIDC] Backport to test

* [KS-OIDC] Backport to test: the other way

* [KS-OIDC] Backport to test: convert to string

* [KS-OIDC] Backport to test: Hint from @wansir

* [KS-OIDC] Backport to test: Damn Space
This commit is contained in:
hnajib
2022-07-07 05:09:35 +02:00
committed by GitHub
parent 641c73c010
commit 45a062593f
2 changed files with 3 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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"))
})