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

Social login: Custom token claim based on request object #600

Open
mateokurti opened this issue Mar 16, 2024 · 1 comment
Open

Social login: Custom token claim based on request object #600

mateokurti opened this issue Mar 16, 2024 · 1 comment

Comments

@mateokurti
Copy link

I want to be able to add a claim on the token, based on something else apart from user. The classmethod get_token only accepts user as an argument, allowing to add claims related directly to the user.

However, I want to add a claim that is related to the user and to the request. It's kind of a tenant claim, which is specified on the sign-in request. It is validated to check if the user has access to the tenant, but the relationship between the user and the tenant is M2M, meaning that I can't get this information from the user alone.

I need to access it from context, but as get_token is a classmethod, I don't have access to it. Is this possible?

@quanta-kt
Copy link

I have the same use case, I would like to add the tenant claim in the JWT so that each authenticated request is associated with one without having to set an extra header.

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

No branches or pull requests

2 participants