Repository navigation
Description
Summary
Concourse's embedded Dex supports the RFC 8693 token-exchange grant
(urn:ietf:params:oauth:grant-type:token-exchange) and advertises it in
/sky/issuer/.well-known/openid-configuration. The exchange itself succeeds —
Dex verifies the subject token against the upstream connector and mints a
token — but the client always receives HTTP 500 with an empty body, and the
minted token is discarded.
Root cause: skymarshal/token/access_token.go (StoreAccessToken) intercepts
every 2xx response from /sky/issuer/token, unmarshals the JSON, and parses
the id_token field to convert it into a stored opaque access token. Per
RFC 8693 section 2.2.1, a token-exchange response carries the issued token in
access_token and has no id_token member (Dex's handleTokenExchange
puts the token in access_token for both requested_token_type values and
never sets IDToken). The middleware therefore calls
claimsParser.ParseClaims(""), which fails, and the error path writes a bare
500 without a body, dropping Dex's successful response.
Proposed fix: when id_token is absent from Dex's response, parse the claims
from access_token instead (it is the same RS256-signed Dex JWT in the
exchange case). This converts exchanged tokens into stored opaque Concourse
access tokens exactly like every other grant. I have a small candidate patch
for skymarshal/token/access_token.go and am happy to open a PR.
Steps to Reproduce
The bug is in Concourse's post-processing of the token endpoint response, so
it reproduces with any OIDC connector for which the token exchange itself
succeeds (i.e. any connector whose TokenIdentity accepts the subject token).
We hit it with Microsoft Entra; a locally run Concourse (docker compose up)
pointing its oidc connector at any IdP reproduces it the same way:
docker compose up -d a Concourse whose web node has an OIDC connector
configured (CONCOURSE_OIDC_ISSUER etc. pointing at your IdP), with
CONCOURSE_OIDC_DISABLE_GET_USER_INFO=true so that id_token subject
verification is done locally.
Obtain a valid token from the upstream IdP whose issuer/signature Dex can
verify (for Entra: an access token with the Concourse app registration as
audience and a v2.0 issuer).
Perform the exchange against Concourse's token endpoint:
curl -i http://localhost:8080/sky/issuer/token
-u 'fly:Zmx5'
--data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:token-exchange'
--data-urlencode 'connector_id=oidc'
--data-urlencode 'subject_token_type=urn:ietf:params:oauth:token-type:id_token'
--data-urlencode "subject_token=${UPSTREAM_TOKEN}"
--data-urlencode 'requested_token_type=urn:ietf:params:oauth:token-type:access_token'
--data-urlencode 'scope=openid profile email federated:id groups'
Observe the response and the web node logs.
Expected Results
A 200 response containing a Concourse-usable token, as for any other grant
against /sky/issuer/token — i.e. the RFC 8693 response rewritten to carry a
stored opaque Concourse access token, the same post-processing applied to
authorization-code and password grants.
Actual Results
HTTP 500 with an empty body, on every attempt, for both
requested_token_type values. The web node logs (with the timestamp matching
the request):
{"source":"atc","message":"atc.dex-server.token-request.parse-id-token",
"data":{"error":"go-jose/go-jose: compact JWS format must have three parts","session":"..."}}
Dex itself succeeded: the subject token was verified and a token was minted
(no atc.dex error precedes the middleware error). The middleware discards
that successful response. Requesting
requested_token_type=urn:ietf:params:oauth:token-type:id_token does not
help — per RFC 8693 the issued ID token still arrives in access_token, and
the id_token field the middleware reads remains absent.
Web Node(s) configuration
One web node (deployed via the Concourse Helm chart 19.0.2). Relevant auth
configuration, secrets omitted:
CONCOURSE_OIDC_DISPLAY_NAME: Azure Entra
CONCOURSE_OIDC_ISSUER: https://login.microsoftonline.com//v2.0
CONCOURSE_OIDC_SCOPE: openid email profile
CONCOURSE_OIDC_USER_NAME_KEY: preferred_username
CONCOURSE_OIDC_GROUPS_KEY: roles
CONCOURSE_OIDC_SKIP_EMAIL_VERIFIED_VALIDATION: "true"
CONCOURSE_OIDC_DISABLE_GET_USER_INFO: "true"
Worker(s) configuration
Three workers (CONCOURSE_RUNTIME: containerd,
CONCOURSE_BAGGAGECLAIM_DRIVER: overlay). Not relevant to this bug — the
failure is entirely in the web node's token endpoint middleware.
Concourse Version
7.14.x (Helm chart 19.0.2). The affected code in skymarshal/token/access_token.go is unchanged on current master.
Browser (if applicable)
N/A — API-only, reproducible with curl.
Did this use to work?
No. StoreAccessToken predates Dex's token-exchange support (inherited when the Dex fork was rebased), and it has always assumed an id_token field in every successful token response, so this grant has never worked against the embedded Dex on any Concourse version.
Activity
skymarshal: behaviour: handle RFC 8693 token-exchange responses