Fix the etcd PKCE AuthCode deserialization #1908
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This change fixes a bug in the PKCE implementation when using
etcdas the storage engine. As of v2.27.0, this combination is broken and acode_verifiercannot be used to request a token.Specifically, you will get an errant error
No PKCE flow started. Cannot check code_verifiererror when requesting/tokendespite the fact that acode_challengeandcode_challenge_methodwere indeed provided to/auth.This PR also adds a PKCE AuthCode round-trip check to the storage conformance tests. Indeed that test fails on v2.27, and now it passes 🙏 .
What this PR does / why we need it
CreateAuthCode, the etcd storage implementation usesfromStorageAuthCode()to convert astorage.AuthCodeinto the etcd variant.GetAuthCode, however, the implementation attempts to directly unmarshal the json into thestorage.AuthCodewithout the etcd intermediate.AuthCodestruct, but is nested in thestorage.AuthCodestruct.CodeChallengeis always the empty string.handlers.go:820always getscodeChallengeFromStorage = ""and falls into the error condition.toStorageAuthCodeequivalent to correctly deserialize, and uses it.Special notes for your reviewer
Enjoy! 💖
Does this PR introduce a user-facing change?