Repository navigation
skymarshal: behaviour: handle RFC 8693 token-exchange responses - #9638
Conversation
Dex's token-exchange grant returns the issued token in access_token and, per RFC 8693 section 2.2.1, has no id_token member. StoreAccessToken assumed every 2xx from /sky/issuer/token carried an id_token, so it parsed an empty string, failed, and converted Dex's successful response into an empty 500 - making token exchange against the embedded Dex unusable. Fall back to parsing claims from access_token so exchanged tokens are converted to stored Concourse access tokens like every other grant. concourse#9636 Signed-off-by: ibaileyStingray <[email protected]>
|
|
|
Thanks for opening an issue and opening a PR to fix it. I'll spend some time validating the issue and your proposed fix. I like to be extra cautious around any auth changes. The proposed change does seem good and I appreciate you adding tests for it as well! When you get a chance can you please do the EasyCLA sign-off by clicking the link in the previous comment. TY! |
|
Thanks you for you feedback. Being an corporate contributor, the easyCLA should take a few days. But I am actively working for it to reach the good person desk :). Meanwhile, I'll stay available for any question or suggestion from your side. |
|
easyCLA step approved. thanks for your patience |
|
I'm going to need your help reproducing the original issue and verifying that this PR fixes it. I tried puzzling it out on my own (and with Claude) but couldn't get this working. In the issue you opened, you mention getting an But I got back HTTP 401 and Not sure what you're using for your local OIDC. The one we used to use in the More precise steps to reproduce would be helpful. |
|
I pushed the local oidc setup I had to |
|
Thanks for pushing the local OIDC setup — I reproduced the issue and verified the fix with it. Two things explain what you saw:
Repro steps (from a checkout of master, then again with this PR applied):
Mint an upstream ID token headlessly via local-idp's login API (no browser needed): Then run the exchange from the issue: On current master: HTTP 500 with an empty body, and the web log shows the failure in the Concourse middleware (not Dex): With this PR applied: HTTP 200 with the RFC 8693 response intact and an opaque Concourse token: and the returned token authenticates successfully against GET /api/v1/user. |
taylorsilva
left a comment
There was a problem hiding this comment.
TY for the detailed steps. Was able to reproduce it locally and verify the output is what you said it would be. Code changes and tests look good to me as well. Thanks again for the PR!
Changes proposed by this PR
closes #9636
Make sure to follow all PR requirements.
Notes to reviewer
the exchange grant would hand the client a raw Dex JWT, which the ATC no
longer accepts (Concourse >= 7 validates opaque DB-backed tokens). Rewriting
keeps exchange clients on the same token model as
flylogin, including theuser row creation (
CreateOrUpdateUser) and the short-header benefit thatmotivated opaque tokens in the first place.
grant_typefrom the request? The response-side check(
id_tokenempty) is more robust — the request body has already beenconsumed by the Dex handler, and any 2xx response lacking
id_tokenpreviously produced a guaranteed 500, so the fallback is strictly an
improvement.
honest:
omitemptystops an empty"id_token": ""appearing in exchangeresponses, and
issued_token_typeis preserved instead of silently droppedon re-marshal.
skymarshal/token/access_token_test.go: feed themiddleware a fake Dex 200 with
access_token= signed JWT and noid_token, assert a 200 with an opaque token and stored claims.