-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
MongoEngine's Django User Auth Model Not Supported #59
Comments
Hi @rfkrocktk - Would love to work on this but without a paying client who needs it, I can't justify the time. OTOH, we do accept contributions. ;-) |
@rfkrocktk would subclassing the user model to contain that field like this work for you? class MyAuthUserModel(mongo_auth.MongoUser):
"""I am a cool subclass of Mongo's user model"""
@property
def user_permissions(self):
['list', 'of', 'required', 'permissions', 'generated'] Although, I'm confused why this doesn't work: https://github.com/pydanny/django-mongonaut/blob/master/mongonaut/sites.py#L49 Seems it only checks for |
Not sure, but even when I'm logged in using Django's auth system (User object replaced with MongoEngine's Django replacement), I get a 403 when trying to access mongonaut. |
If you go to a e.g. from my_app.model import MyCusotmUser
user = MyCustomUser.object.get(username='my-user-name')
user.is_staff == True
user.is_active == True How would the user have been marked as staff? I had to write a custom command awhile back if I remember to properly add a superuser when I used mongoengine in the past. |
Update: I can't even seem to get it working without using MongoEngine as an authentication source.
Yet, when I try to access mongonaut, I see the following: ...and I get a 403. Any ideas? |
Without a look at the code giving the 403, I'm not going to be very useful other than my comment above, sorry. |
Same problem here: Django 1.5.1 with MongoEngine 0.8.4 as models backend. Getting "You do not have permissions to access this content." error trying to access to mongonaut. 'is_active', 'is_staff' and 'is_superuser' of the admin user are set to True. |
I think I've tracked down the issue: mongonaut/mixins.py:35:
However, permissions seem to never be added to the context anywhere in the codebase, so how would it ever work? Strange. |
Okay, so here's a patch which seems to work: mongonaut/mixins.py:35:
Now I've got a |
@rfkrocktk -- I'm also getting the same
@garrypolley , @pydanny |
I worked around it somehow. Can't remember now :-/
|
OK I've got it working now ... it appears to be the version of Django. When I upgrade to Django 1.5 it works. With Django 1.4 (as per examples/requirements.txt) I get the NoReverseMatch error. |
I have the same problem
|
it appears that there is no url import in templates like |
Or... @ashishsingh2205, you could submit a pull request. 😉 |
solve This issue 👍 first Login with 127.0.0.1:8000/admin/ then go to 127.0.0.1:8000/mongonaut/ |
Given the age and new ticket to upgrade to new Django I'm going to close this ticket: #94 |
Due to a limitation in MongoEngine, User objects stored in MongoEngine don't have a
user_permissions
field, which makes it impossible to log into mongonaut when using MongoEngine's user model replacement:Admittedly, this is a bug in MongoEngine, but it'd be awesome to see a workaround in the meantime in mongonaut to enable users to log in until this is fixed upstream.
A patch for this would consist of simply replacing the use of the permissions API with a check to
user.is_staff and user.is_active
.The text was updated successfully, but these errors were encountered: