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

Additional arguments to the claim callable #36

Open
willstott101 opened this issue Nov 5, 2021 · 3 comments
Open

Additional arguments to the claim callable #36

willstott101 opened this issue Nov 5, 2021 · 3 comments

Comments

@willstott101
Copy link
Contributor

I'd like to implement a double submit cookie for micro-service CSRF. I'm not sure how to do this cleanly without expanding the arguments the configurable CALLABLE takes. As I'll need to add a claim based on response data (whether I parse the response or just access an attribute) I need to receive the response (and/or request) in the CALLABLE.

I'd like to propose we suggest users configure their callable with def my_callable(..., **kwargs): so in the future this can be expanded, and then pass in (user=..., request=..., response=...) instead of (user).

Would you be interested in receiving a non-backwards compatible version of this patch? A backwards compatible version might be to have a different configurable callable like FULL_CALLABLE (ideally with a better name).

@btimby
Copy link
Contributor

btimby commented Nov 5, 2021

Honestly, I would be more interested in including CSRF protection directly. Changing the callable signature to be more flexible is also desirable.

@btimby
Copy link
Contributor

btimby commented Nov 9, 2021

As with the other issue, I am OK with omitting user, and passing request and response instead. response could be a kwarg, while request would be required to give the callable access to request.user.

@willstott101 willstott101 changed the title Additional claims Additional arguments to the claim callable Nov 9, 2021
@willstott101
Copy link
Contributor Author

willstott101 commented Nov 9, 2021

Could do... https://github.com/smartfile/django-session-jwt/blob/master/django_session_jwt/middleware/session.py#L181 currently the user object isn't set back onto request, and it'd never be None I guess if we're assuming request.user semantics. But that's fine by me if you happy with that🤷

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