Skip to content

Commit

Permalink
Merge pull request #1 from tuxcanfly/master
Browse files Browse the repository at this point in the history
Added Google Apps support
  • Loading branch information
jeremi committed Dec 30, 2011
2 parents 72aac5e + 1c4461b commit d8ffc30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions django_openid_auth/auth.py
Expand Up @@ -46,6 +46,10 @@ class OpenIDBackend:
"""A django.contrib.auth backend that authenticates the user based on
an OpenID response."""

supports_object_permissions = False
supports_anonymous_user = False
supports_inactive_user = False

def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
Expand Down
12 changes: 7 additions & 5 deletions django_openid_auth/views.py
Expand Up @@ -136,16 +136,18 @@ def parse_openid_response(request):


def login_begin(request, template_name='openid/login.html',
login_complete_view='openid-complete',
openid_url=None,
login_complete_url=None,
form_class=OpenIDLoginForm,
render_failure=default_render_failure,
redirect_field_name=REDIRECT_FIELD_NAME):
"""Begin an OpenID login request, possibly asking for an identity URL."""
redirect_to = request.REQUEST.get(redirect_field_name, '')

# Get the OpenID URL to try. First see if we've been configured
# to use a fixed server URL.
openid_url = conf.SSO_SERVER_URL
# Dynamically configurable SSO_SERVER_URL and SSO_RETURN_URL
# Useful for Google Apps authentication
openid_url = openid_url or conf.SSO_SERVER_URL
login_complete_url = login_complete_url or reverse('openid-complete')

if openid_url is None:
if request.POST:
Expand Down Expand Up @@ -199,7 +201,7 @@ def login_begin(request, template_name='openid/login.html',

# Construct the request completion URL, including the page we
# should redirect to.
return_to = request.build_absolute_uri(str(getattr(settings, 'OPENID_SSO_RETURN_URL', reverse(login_complete_view))))
return_to = request.build_absolute_uri(str(getattr(settings, 'OPENID_SSO_RETURN_URL', login_complete_url)))
if redirect_to:
if '?' in return_to:
return_to += '&'
Expand Down

0 comments on commit d8ffc30

Please sign in to comment.