Repository navigation
Conversation
Keycloak rejects the device authorization request with "Missing parameter: code_challenge_method" when the client enforces PKCE, so `step oauth --console` and commands that use it, like `step ssh login --console`, fail with those clients. Retry the request with a code challenge when the server asks for one, and send the code verifier when polling for the token. The PKCE parameters are not sent by default because RFC 8628 doesn't define them, and Google rejects a token request that has a code_verifier. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Name of feature:
PKCE in the OAuth device authorization flow
Pain or issue this feature alleviates:
step oauth --console, and sostep ssh login --console, fails with a Keycloak client that enforces PKCE. Keycloak checks the PKCE setting of the client in the device flow too (DeviceEndpoint.java), andstepstops with:With this change,
stepretries the request with an S256 code challenge when the server asks for one, and then sends thecode_verifierwith the token request.I first sent the PKCE parameters on every request, but that breaks Google. It rejects the token request with
Parameter not allowed for this message type: code_verifier. Sosteponly sends them after the server asks, and the requests to servers that work today stay the same.Is there documentation on how to use this feature? If so, where?
It needs no configuration. I added a line to the changelog.
In what environments or workflows is this feature explicitly NOT supported (if any)?
A client that requires the
plainmethod. The retry looks forcode_challengein theerror_description, which is what Keycloak returns. I don't know of another server that requires PKCE in this flow.Supporting links/other PRs/issues:
How I tested it:
The new test covers both paths and fails without the fix.
make lintreports 0 issues.make testpasses exceptTest_healthAction, which also fails on master now and then (1 of 20 runs here).Keycloak 26.8.2 in Docker with two public clients. I ran
step oauth --provider <issuer> --client-id <client> --console --console-flow device --oidc --bareand signed in as a test user:stepKeycloak does check the verifier. A token request without it gets
PKCE code verifier not specified, and a wrong one getsPKCE verification failed: Code mismatch.Our own Keycloak with the OIDC provisioner of step-ca:
step ssh login --consolefails with v0.30.2 and returns an SSH certificate with this PR.I did not sign in with Google. The test checks that a server that doesn't ask for PKCE gets no PKCE parameter, so those requests are the same as before.
💔Thank you!
🤖 Generated with Claude Code