Open tm1000 opened 6 years ago
Hello @tm1000
Thank you for your report.
When we do not have a request object available, I believe we have no way to know the IP address of the remote user. Creating a session for an user without specifying an IP address is rather insure: the token can then be used from any IP address. This makes me really uncomfortable supporting a missing request object.
Maybe I am missing something:
None
as request object: https://github.com/WeblateOrg/weblate/blob/master/weblate/accounts/forms.py#L569 ; any clue?Haha, just realized YOU added the request to their code base from a PR a few a hours ago. Since they accepted and merged it, I believe it's safer to use your fix (which seems cleaner).
@pmuller That's fine but you are still violating the Django API. It specifically says "request is an HttpRequest and may be None if it wasn’t provided to authenticate() (which passes it on to the backend).". So Request can be of type None and this module should be able to deal with that.
This makes me really uncomfortable supporting a missing request object.
Right but the Django API states "request is an HttpRequest and may be None". Regardless it's fixed in Weblate, but this may be an issue with other systems that use the Django framework and this crowd module (since this is pretty much the only good one)
On that note thank you for making this module and saving me much headache in writing it myself. You did a great job!
I fully understand your concern @tm1000, but as this module is critical for a webapp security, I do not think it's a good idea to compromise on security. Let's reopen the issue to keep track of this in the event someone comes up with a good idea abut how to fix it without creating sessions not tied to a specific source ip address.
I also just ran into this issue while calling Django authenticate()
. I understand the concern and use of the REMOTE_ADDR
, but I think adding an assert
would just save some debugging time.
assert(request, 'django-crowd-auth requires authenticate() to provide a request object to validate the remote address')
https://docs.djangoproject.com/en/2.0/topics/auth/customizing/#authentication-backends