docs(spec): make grant_type binding at POST /token - #21
Draft
antstanley wants to merge 1 commit into
Draft
Conversation
antstanley
force-pushed
the
spec/bind-grant-type-at-token-endpoint
branch
2 times, most recently
from
August 5, 2026 08:22
aa91730 to
b5c9a33
Compare
antstanley
changed the base branch from
main
to
spec/validate-revoke-token-claims
August 5, 2026 08:22
antstanley
marked this pull request as draft
August 5, 2026 08:25
This was referenced Aug 5, 2026
antstanley
force-pushed
the
spec/bind-grant-type-at-token-endpoint
branch
2 times, most recently
from
August 5, 2026 11:29
9e11f1e to
ac182ef
Compare
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
antstanley
force-pushed
the
spec/bind-grant-type-at-token-endpoint
branch
from
August 5, 2026 12:01
ac182ef to
26b4647
Compare
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.
Note
Stacked PR 6 of 16 — part of stack #35, which targets
main.Base: #19 (
spec/validate-revoke-token-claims) · Followed by: #20This PR's diff shows only its own change. Merge the stack bottom-up; do not merge this before its base.
Why it sits at position 6: Replaces
ExchangeRequest's optional fields with anExchangeCredentialenum, which invalidates #20's field-presence rationale and relocatesprovider_access_token. Also carries the RFC 6749 §5.1no-storeheaders.Scope of this PR
This PR currently carries the change spec. It will also carry the implementation plan and the build work for that spec — plan and code land as later commits on this same branch, so the spec, its plan, and its implementation review and merge as one unit.
Review order within the PR: spec first, then plan, then implementation.
Change spec proposing that
grant_typeselect the flow atPOST /token.Problem.
crates/core/src/service/exchange.rsselects the flow by which optional fields are present, not by the declaredgrant_type. Supplying anid_tokenfield while declaringgrant_type=authorization_coderuns the direct ID-token path and skips code redemption entirely, along with theredirect_urirequirement the authorization-code flow depends on.Proposed delta. The declared
grant_typebecomes the sole selector, with a closed per-grant parameter set —authorization_coderequiresprovider/code/redirect_uri,id_tokenrequiresprovider/id_token,refresh_tokenrequiresrefresh_token— and any parameter belonging to a different grant is rejected400 invalid_requestrather than ignored.Enforcement is structural rather than a boundary check:
ExchangeRequestloses itsOption<String>fields and its#[derive(Default)]in favour of anExchangeCredentialenum whose variants own their own fields, so an invalid combination cannot be constructed.Notes.
TokenForm.grant_typeis a bareString, a body omitting it currently fails axum's form deserialization and returns 422 plain text, escaping the RFC 6749 error envelope entirely. The spec pins it to400 invalid_requestand gives two implementation routes.id_tokengrant (discovery advertises two grant types while three are accepted), and whether a mismatch should emit aValidationFailedaudit event.Drafted with the
spec-creatorplugin from a deep security scan of the repository at53cbdec9. Spec only — no source changes.