Skip to content

feat: request tokens with a JWT bearer assertion (RFC 7523) - #19

Merged
azmeuk merged 5 commits into
authlib:mainfrom
azmeuk:feat/jwt-bearer-grant
Nov 12, 2026
Merged

azmeuk merged 5 commits into
authlib:mainfrom
azmeuk:feat/jwt-bearer-grant

Conversation

@azmeuk

@azmeuk azmeuk commented Nov 12, 2026

Copy link
Copy Markdown
Member

Part of #2.

This adds the JWT bearer grant type (RFC 7523 §2.1) to the direct grants. The client sends a signed JWT that says who the tokens are for, and the provider issues tokens for this subject.

The assertion can be:

  • signed with the client key, with the algorithm of private_key_jwt,
  • signed with the client secret, with HS256,
  • pasted, for an assertion issued by another party.

The form sets the subject, the issuer (the client ID by default), the audience (the issuer or the token endpoint), the lifetime and extra claims. The extra claims cannot replace the claims the form sets, except jti.

The preview shows the header and the claims as Authlib signs them. A pasted assertion is decoded without checking the signature, with its dates, and with a warning when it has expired or when its audience is neither the issuer nor the token endpoint.

When the token response has an ID token, it is checked before the tokens are kept, like for the password grant. The user of the ID token is then signed in. Otherwise, the page says who the tokens are for.

The ID token claims are now passed to userinfo(), so Authlib rejects a
response for another user (OIDC Core §5.3.2). A signed response that
cannot be validated now shows an error instead of a server error.
Authlib 1.10 puts the kid of the key in the assertion header.
Per OIDC Discovery §4.3 and RFC 8414 §3.3, the issuer of the metadata
must be the issuer URL the metadata was fetched with. A provider that
gives another issuer, or none, is now refused.
The assertion is signed with the client key or the client secret,
or pasted. The preview shows its header and claims, and decodes a
pasted assertion.
@azmeuk
azmeuk enabled auto-merge November 12, 2026 16:56
@azmeuk
azmeuk merged commit 27ce35d into authlib:main Nov 12, 2026
13 checks passed
@azmeuk
azmeuk deleted the feat/jwt-bearer-grant branch November 12, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant