-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Populate the subject property in the AccesToken in get_access_token() #4266
Copy link
Copy link
Open
Labels
authRelated to authentication (Bearer, JWT, OAuth, WorkOS) for client or server.Related to authentication (Bearer, JWT, OAuth, WorkOS) for client or server.bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.Something isn't working. Reports of errors, unexpected behavior, or broken functionality.serverRelated to FastMCP server implementation or server-side functionality.Related to FastMCP server implementation or server-side functionality.
Metadata
Metadata
Assignees
Labels
authRelated to authentication (Bearer, JWT, OAuth, WorkOS) for client or server.Related to authentication (Bearer, JWT, OAuth, WorkOS) for client or server.bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.Something isn't working. Reports of errors, unexpected behavior, or broken functionality.serverRelated to FastMCP server implementation or server-side functionality.Related to FastMCP server implementation or server-side functionality.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Enhancement
Problem
get_access_token()returns anAccessTokenobject which does not contain asubjectproperty.fastmcp/fastmcp_slim/fastmcp/server/dependencies.py
Lines 519 to 527 in 0f4f78c
This makes early logging for authentication incomplete (and in my case made my troubleshooting of auth issue quite tedious).
Reproduction
Just invoke
get_access_token()and print the output. It will return anAccessTokenwith the property subject set toNonedespite having a "sub" in the actual access token returned by the authorization server.Expected
As per RFC9068 - RFC JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens the "sub" claim is REQUIRED and must be provided by the authorization server. I suggest
subjectshould be set withsubject=access_token_as_dict["subject"],.