1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-25 14:50:29 +00:00

[thirdpart] Add shibboleth

This commit is contained in:
zhengxie
2014-12-17 14:29:29 +08:00
parent c2a07137ef
commit c914fe30c5
12 changed files with 458 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
"""
Decorators to use with Shibboleth.
"""
from django.conf import settings
from django.contrib import auth
from middleware import ShibbolethRemoteUserMiddleware
def login_optional(func):
"""
Decorator to pull Shib attributes and log user in, if possible. Does not
enforce login.
"""
def decorator(request,*args, **kwargs):
#Do nothing if the remoteuser backend isn't activated
if 'shibboleth.backends.ShibbolethRemoteUserBackend' not in settings.AUTHENTICATION_BACKENDS:
pass
else:
shib = ShibbolethRemoteUserMiddleware()
#Proccess the request with the Shib middlemare, which will log the
#user in if we can.
proc = shib.process_request(request)
return func(request, *args, **kwargs)
return decorator