django-authentication

Do Django custom authentication backends need to take a password?

Here's how my university handles authentication: we redirect the user to a website, they enter in their username and password, then they get redirected back to us with the username and a login key passed in the query string. When we get the user back, we call a stored procedure in the university's database that takes the username, logi...

django login middleware not working as expected

A quickie, and hopefully an easy one. I'm following the docs at http://docs.djangoproject.com/en/dev/topics/auth/ to get just some simple user authentication in place. I don't have any special requirements at all, I just need to know if a user is logged in or not, that's about it. I'm using the login_required decorator, and it's working ...

How can I detect multiple logins into a Django web application from different locations?

I want to only allow one authenticated session at a time for an individual login in my Django application. So if a user is logged into the webpage on a given IP address, and those same user credentials are used to login from a different IP address I want to do something (either logout the first user or deny access to the second user.) ...

Django: Populate user ID when saving a model

Hello, I have a model with a created_by field that is linked to the standard Django User model. I need to automatically populate this with the ID of the current User when the model is saved. I can't do this at the Admin layer, as most parts of the site will not use the built-in Admin. Can anyone advise on how I should go about this? ...

In Django admin, how to filter users by group?

It gives you filter by staff status and superuser status, but what about groups? ...

django Authentication using auth.views

User should be redirected to the Login page after registration and after logout. In both cases there must be a message displayed indicating relevant messages. Using the django.contrib.auth.views.login how do I send these {{ info }} messages. A possible option would be to copy the auth.views to new registration module and include all es...

How to force user logout in django?

In my django app under certain conditions I need to be able to force user logout by a username. Not necessarily the current user who is logged in, but some other user. So the request method in my view doesn't have any session information about the user that I want to logout. I am familiar with django.auth, and with auth.logout method, b...

Django : Adding a property to the User class. Changing it at runtime and UserManager.create_user

For various complicated reasons[1] I need to add extra properties to the Django User class. I can't use either Profile nor the "inheritance" way of doing this. (As in http://stackoverflow.com/questions/44109/extending-the-user-model-with-custom-fields-in-django ) So what I've been doing is including the User class in my local_settings ...

Code reuse between django and appengine Model classes

I created a custom django.auth User class which works with Google Appengine, but it involves a fair amount of copied code (practically every method). It isn't possible to create a subclass because appengine and django have different database models with their own metaclass magic. So my question is this: is there an elegant way to copy...

OpenID in django without local site accounts

I'm working on a django site, which I want the authentication part to work exactly like how Stack Overflow works. A new user comes to the site, they click on "create new account", choose their OpenID provider, get validated, then an account is created for them with "openiduser4356" or something as the username. The user can then go into ...

How to preset the username in Djangos login form?

After being dissatisfied with the existing solutions I wrote an OpenId provider for Django. If now somebody wants to authenticate himself somewhere as http://tejp.de/users/abc/ and needs to login for that, I want to display the login form with the username preset to "abc". The standard functions like redirect_to_login don't seem to prov...

How can make Django permission_required decorator not to redirect already logged-in users to login page, but display some message

How can make Django permission_required decorator not to redirect already logged-in users to login page, but display some message like Insufficient permissions? Thank you. ...

When using sub-domains for a Django site, how can you share django logins across sub-domains on localhost?

I want to let the same user session span across: site.com sub1.site.com sub2.site.com How can I do this in Django? With the default auth user package it seems to require the user to login to all 3 sites each time with a different session. How can they share the same login cookie and session-id? UPDATE: Using the SESSION_COOKIE_DOMAIN...

(Django) Sharing authentication across two sites that are on different domains

I have two sites say foo.com and bar.com and are both Django based. Primary registration occurs on foo.com (I'd like the main user db to be here) and I'd like for three things to happen: 1) User that logs in to foo.com is automatically able to access bar.com without logging in again 2) User that logs in to bar.com directly is authentic...

django - limit users to edit only their own information

I'm playing around with django and built a small app where a user can access their info via the url http:///localhost:8000/username/info/ . I want to add the ability to edit that info through http:///localhost:8000/username/info/edit/, but also want to make sure the currently logged in user (using django.contrib.auth) can access only his...

[Django] Custom authentication backend functions in some cases, not always

I am using a custom authentication backend built on CAS and LDAP in a Django project. I intend to have it set up such that it can get permissions based on the what LDAP groups a user is part of. However, I have had problems with it and took a step back, so that both has_perm and has_module_perms in my backend return True always. What I ...

How could I create a screen that would batch create a bunch of Django auth users?

I want to create a helper screen that can create a bunch of Django auth users on my site and have those accounts setup the same exact way as if they were done one by one through the Django auth GUI signup. What methods from Django auth would I have to use in my view to accomplish this? ...

Best way to add convenience methods to a Django Auth User model?

I want to add a convenience/model method to the django.contrib.auth.models.User model. What is the best practice for doing this since, last time I checked, extending the User model was considered bad practice. I have a separate custom UserProfile model. Should I be using that for all User-related convenience methods? ...

How to enforce account based separation in Django

I have a Django app which has a single-account model. We are converting this to be multi-account, so almost every model will have a ForeignKey(Account). What is the easiest way to make sure that each Account (each account is in its own subdomain) can only access its own data? We have a middleware that populates the subdomain, and the cu...

How to get Permissions to inherit from User's Groups?

I'm trying to figure out Django Groups and the documentation is pretty bare on the site. For example, you can use the decorator permission_required() to check the permissions, however, this only checks if you have assigned permissions directly. I have assigned Users to Groups which have Permissions setup. When using Django's permissio...