Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support standard JWT payload #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JoshuaMathias
Copy link

@JoshuaMathias JoshuaMathias commented Dec 5, 2023

I found 3 significant issues that directly prevented me from using this library for decoding a JWT token that was created by separate code:

  1. Specifying "aud" as audience and "iss" as issuer to jose's decode function, as well as any other kwargs that jose supports. This can now be done with a decode_kwargs parameter.
  2. Use of the standard "sub" instead of "subject" for subject. I made "sub" the default so this change could affect existing applications that already have tokens generated, but you can also specify subject_key="subject".
  3. Instead of only returning subject and jti in the credentials payload available to the API code, return the whole payload so all data is available. I implemented this by having JwtAuthorizationCredentials inherit from dict and represent the payload directly.

After the above fixes, I was able to get my use case to work.

Example use:
access_security = JwtAccessBearer(secret_key='your-secret-key'), auto_error=True, decode_kwargs={"audience": "My-Service", "issuer": "whoever made the key"}, subject_key="sub")

Since this repository doesn't appear to be maintained and I need this right away, this is now found on pip at https://pypi.org/project/fastapi-jwt-extended/1.0.0/
pip install fastapi_jwt_extended

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