On Mon, Jul 4, 2011 at 10:15 PM, Josh Stratton <strat...@innovationsimple.com> wrote: > I've setup my authentication system to use the standard name/password with > good results, but some of the users are coming directly from Google Apps > with an OpenID I've authenticated by hand. What I'd like is if they are > authenticated from Google Apps, I can just call > auth_login, but they haven't actually been "authenticated" in django's > eyes. All I'd like to do is log in as if they had typed their > username and password. If I just try to logon the user, I get an error > saying the "backend" hasn't been set. Right now I can hack a login by > setting the backend to the same one used by the other method, but when I go > to the another tab and go back to the site, I see that I'm not actually > logged in on that page, like something isn't stored in the session > correctly. This seems like it should be a simple problem, but it's > extremely frustrating. I'd just like to say, "Hey, I trust this person, log > them in even though I don't know their password". > > Thanks. >
Users must be authenticated before you call login. You can authenticate them using a custom auth backend: https://docs.djangoproject.com/en/1.3/topics/auth/#handling-authorization-in-custom-backends Define your own custom auth backend (in addition to the current one you are using) which takes an optional 'openid_authenticated' argument. The authenticate method in the auth backend should simply find the user with the appropriate username, and return it. When you receive a user authenticated through openid, simply call django.contrib.auth.authenticate, passing this new additional argument. The user returned from djanog.contrib.auth.authenticate will then have the appropriate backend set, and login will correctly store the right parameters in the users session. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.