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
etcd
as the storage engine. As of v2.27.0, this combination is broken and acode_verifier
cannot be used to request a token.Specifically, you will get an errant error
No PKCE flow started. Cannot check code_verifier
error when requesting/token
despite the fact that acode_challenge
andcode_challenge_method
were 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.AuthCode
into the etcd variant.GetAuthCode
, however, the implementation attempts to directly unmarshal the json into thestorage.AuthCode
without the etcd intermediate.AuthCode
struct, but is nested in thestorage.AuthCode
struct.CodeChallenge
is always the empty string.handlers.go:820
always getscodeChallengeFromStorage = ""
and falls into the error condition.toStorageAuthCode
equivalent to correctly deserialize, and uses it.Special notes for your reviewer
Enjoy! 💖
Does this PR introduce a user-facing change?