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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the etcd PKCE AuthCode deserialization #1908

Merged
merged 2 commits into from Jan 13, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion storage/etcd/etcd.go
Expand Up @@ -156,7 +156,11 @@ func (c *conn) CreateAuthCode(a storage.AuthCode) error {
func (c *conn) GetAuthCode(id string) (a storage.AuthCode, err error) {
ctx, cancel := context.WithTimeout(context.Background(), defaultStorageTimeout)
defer cancel()
err = c.getKey(ctx, keyID(authCodePrefix, id), &a)
var ac AuthCode
err = c.getKey(ctx, keyID(authCodePrefix, id), &ac)
if err == nil {
a = toStorageAuthCode(ac)
}
return a, err
}

Expand Down
18 changes: 18 additions & 0 deletions storage/etcd/types.go
Expand Up @@ -26,6 +26,24 @@ type AuthCode struct {
CodeChallengeMethod string `json:"code_challenge_method,omitempty"`
}

func toStorageAuthCode(a AuthCode) storage.AuthCode {
return storage.AuthCode{
ID: a.ID,
ClientID: a.ClientID,
RedirectURI: a.RedirectURI,
ConnectorID: a.ConnectorID,
ConnectorData: a.ConnectorData,
Nonce: a.Nonce,
Scopes: a.Scopes,
Claims: toStorageClaims(a.Claims),
Expiry: a.Expiry,
PKCE: storage.PKCE{
CodeChallenge: a.CodeChallenge,
CodeChallengeMethod: a.CodeChallengeMethod,
},
}
}

func fromStorageAuthCode(a storage.AuthCode) AuthCode {
return AuthCode{
ID: a.ID,
Expand Down