-
-
Notifications
You must be signed in to change notification settings - Fork 800
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
django-axes compatibility #712
Comments
So I did manage to get this working in the end, I managed to do it by editing just the custom validator for DOT and it's an extremely dirty hack so this is more if anyone else is having the same issue rather than any sort of permanent fix:
|
oAuth is designed to be worked with django rest framework etc. |
It would be ideal if the request objects it uses had the standard Django attributes so that other tools and packages could function better with them. The Would it be possible to add the I've added a simple example on how to customize a compatible validator for the OAuth toolkit on the Axes docs, but I think updating the stock OAuth validator in the toolkit project could benefit multiple users in the long run. |
this package is only needed with rest based works i guess. id you need django specific then django all auyh woud be a better choice with core django without drf |
@auvipy I don't think you understand what @aleksihakli is saying, django-axes is a user login security tool that inspects the request object at various points in the process and because django-oauth-toolkit doesn't use a standard django HttpRequest() it isn't possible to track API logins. It's not about changing the functionality, it's about django-oauth-toolkit and django-axes working together so that API logins can be tracked as well as website logins. |
Also @aleksihakli your example validators.py doesn't work, the oauthlib.Request() class used by django-oauth-toolkit is hardcoded to error when attributes it doesn't expect are accessed https://github.com/oauthlib/oauthlib/blob/master/oauthlib/common.py#L436 so you can't add arbitrary fields to it. The example I pasted above is the only way I could get it working, by recreating a fake HttpRequest() object. |
Oh, sorry about that! Let's try and get the example in the docs up to date then. Would you like to open a PR for the Axes Are you talking about the |
Sorry yes it is request - wrote that in a rush! OAuthLib returns oauthlib.Request() and my solution fakes a Django HttpRequest() so the attributes can be accessed properly through authenticate(). The correct oauthlib.Request() is then returned from the validator so that django-oauth-toolkit continues to function (edited my comment). I'll try and get a PR sent over today. |
Great! You can build the docs in your own environment with RTD builds the docs automatically from each commit to master in upstream so adding examples does not require a new release. |
Use example from jazzband/django-oauth-toolkit#712 for reference with props to @HCNick for debugging
Use example from jazzband/django-oauth-toolkit#712 for reference with props to @HCNick for debugging
Use example from jazzband/django-oauth-toolkit#712 for reference with props to @HCNick for debugging
#643 should fix one error I'm seeing with axes logging errors due to missing |
Inspired by jazzband/django-oauth-toolkit/issues/712 and solution by @HCNick for more functional authentication
#643 is the wrong fix and the cause of this problem, my bad. Broke production for us. |
We just hit this. Isn't the correct fix for this issue, and also #636, and #808 the patch in #712 (comment)? IIUC:
Finally, it seems to me that a patch like the one above (but possibly without the two axes-specific attributes?) could be applied directly to DOT code, and would work to improve the compatibility of DOT. I'd be happy to author a PR if that would help. |
compatibiity with more backends. Resolves jazzband#712. Resolves jazzband#636. Resolves jazzband#808.
compatibiity with more backends. Resolves jazzband#712. Resolves jazzband#636. Resolves jazzband#808.
compatibiity with more backends. Resolves jazzband#712. Resolves jazzband#636. Resolves jazzband#808.
…biity with more backends. (#949) * Provide django.contrib.auth.authenticate() with a request for compatibiity with more backends. Resolves #712. Resolves #636. Resolves #808. Co-authored-by: Alan Crosswell <[email protected]>
Use example from jazzband/django-oauth-toolkit#712 for reference with props to @HCNick for debugging
Inspired by jazzband/django-oauth-toolkit/issues/712 and solution by @HCNick for more functional authentication
A user recently reported an issue with using
django-oauth-toolkit
withdjango-axes
in jazzband/django-axes#426The problem is that the
request
object offered by thedjango-oauth-toolkit
does not seem to be a DjangoHttpRequest
object with therequest.META
and other necessaryHttpRequest
attributes. Is there an ideal way to offer a solution for compatibility?The text was updated successfully, but these errors were encountered: