mirror of
https://github.com/haiwen/seahub.git
synced 2025-04-28 03:10:45 +00:00
parent
57c8fa967c
commit
62c2f0bc9e
@ -18,19 +18,22 @@ from seahub.base.accounts import User
|
||||
from seahub.base.sudo_mode import update_sudo_mode_ts
|
||||
from seahub.profile.models import Profile
|
||||
from seahub.utils.file_size import get_quota_from_string
|
||||
from seahub.utils.user_permissions import get_user_role
|
||||
|
||||
# Get an instance of a logger
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
conf_dir = os.environ['SEAFILE_CENTRAL_CONF_DIR']
|
||||
sys.path.append(conf_dir)
|
||||
try:
|
||||
from seahub_custom_functions import custom_shibboleth_get_user_role
|
||||
CUSTOM_SHIBBOLETH_GET_USER_ROLE = True
|
||||
except ImportError as e:
|
||||
conf_dir = os.environ['SEAFILE_CENTRAL_CONF_DIR']
|
||||
sys.path.append(conf_dir)
|
||||
try:
|
||||
from seahub_custom_functions import custom_shibboleth_get_user_role
|
||||
CUSTOM_SHIBBOLETH_GET_USER_ROLE = True
|
||||
except ImportError:
|
||||
CUSTOM_SHIBBOLETH_GET_USER_ROLE = False
|
||||
except KeyError:
|
||||
CUSTOM_SHIBBOLETH_GET_USER_ROLE = False
|
||||
|
||||
|
||||
class ShibbolethRemoteUserMiddleware(RemoteUserMiddleware):
|
||||
"""
|
||||
Authentication Middleware for use with Shibboleth. Uses the recommended pattern
|
||||
@ -52,15 +55,15 @@ class ShibbolethRemoteUserMiddleware(RemoteUserMiddleware):
|
||||
" 'django.contrib.auth.middleware.AuthenticationMiddleware'"
|
||||
" before the RemoteUserMiddleware class.")
|
||||
|
||||
#To support logout. If this variable is True, do not
|
||||
#authenticate user and return now.
|
||||
# To support logout. If this variable is True, do not
|
||||
# authenticate user and return now.
|
||||
if request.session.get(LOGOUT_SESSION_KEY) is True:
|
||||
return
|
||||
else:
|
||||
#Delete the shib reauth session key if present.
|
||||
# Delete the shib reauth session key if present.
|
||||
request.session.pop(LOGOUT_SESSION_KEY, None)
|
||||
|
||||
#Locate the remote user header.
|
||||
# Locate the remote user header.
|
||||
# import pprint; pprint.pprint(request.META)
|
||||
try:
|
||||
username = request.META[SHIB_USER_HEADER]
|
||||
@ -119,7 +122,7 @@ class ShibbolethRemoteUserMiddleware(RemoteUserMiddleware):
|
||||
if user_role:
|
||||
self.update_user_quota(user, user_role)
|
||||
|
||||
#setup session.
|
||||
# setup session.
|
||||
self.setup_session(request)
|
||||
request.shib_login = True
|
||||
|
||||
@ -253,5 +256,6 @@ class ShibbolethRemoteUserMiddleware(RemoteUserMiddleware):
|
||||
error = True
|
||||
return shib_attrs, error
|
||||
|
||||
|
||||
class ShibbolethValidationError(Exception):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user