yezz123 / authx

Ready-to-use and customizable Authentications and Oauth2 management for FastAPI ✨
https://authx.yezz.me/
MIT License
771 stars 48 forks source link

Additional data are not passed to the JWT token #602

Closed dist3r closed 1 month ago

dist3r commented 2 months ago

Hi!

Thank you for the great work on this library!

I encountered an issue when trying to pass additional data to a JWT token. According to the documentation, the method to pass these data should work by passing keyword arguments to create_access_token and create_refresh_token methods, but it seems the implementation in the source code does not align with this - it seems that it's needed to pass additional data as dict in "data" argument.

What's more, it looks like the “data” argument stops being passed to subsequent methods in the call chain at some stage. The following code snippet seems to be key: https://github.com/yezz123/authx/blob/5b42c59295301ecce4d80f57113900f4e5f16e53/authx/schema.py#L102

Given the above, currently there is no official way to pass additional data to JWT tokens (other than dirty hacks directly calling internal methods of the library).

Could you please take a look into this?

yezz123 commented 2 months ago

Hi! @dist3r

Thanks for pointing out the issue with passing additional data to JWT tokens. I'll investigate and enhance the implementation to align with the documentation. The data argument isn't passed correctly through the call chain.

I appreciate your patience and will update you on the progress.