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

AllAuth should skip auth backends without get_user #1601

Closed
dylanmccall opened this issue Feb 3, 2017 · 1 comment
Closed

AllAuth should skip auth backends without get_user #1601

dylanmccall opened this issue Feb 3, 2017 · 1 comment
Labels

Comments

@dylanmccall
Copy link

Our application uses django-rules for permissions, and it has recently added AllAuth for authentication. However, after logging in, we were getting the following error from any code that tries to access request.user...

'ObjectPermissionBackend' object has no attribute 'get_user'"

ObjectPermissionBackend is an auth backend for django-rules that provides per-object authorization, but (by design) does not include a get_user function. There is a related issue report in django-rules: dfunckt/django-rules#46. This was fixed by a change in Django 1.11: https://code.djangoproject.com/ticket/27542. Django's force_login function used to always assign the first auth backend to a user when logging in.

Looks like AllAuth has a very similar mechanism over here, except missing that fix:

https://github.com/pennersr/django-allauth/blame/master/allauth/account/adapter.py#L344

I suspect AllAuth's login function, like Django's, should make sure to select the first auth backend that has a get_user function, rather than always going for the first auth backend.

@dylanmccall dylanmccall changed the title AllAuth should skip auth bakcends without get_user AllAuth should skip auth backends without get_user Feb 3, 2017
@pennersr
Copy link
Owner

pennersr commented Feb 4, 2017

True, needs logic similar to this:

django/django@47744a0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants