Skip to content
Snippets Groups Projects
Commit db69872f authored by Steffen Vogel's avatar Steffen Vogel :santa_tone2:
Browse files

Rename old usernames based on pesistent-hash to pairwise-id usernames

This is a special migration strategy solely for RWTHjupyter!
parent 72cab95b
Branches
Tags
No related merge requests found
......@@ -10,13 +10,24 @@ from traitlets import Unicode
class RemoteUserLoginHandler(BaseHandler):
def get(self):
header_name = self.authenticator.header_name
remote_user = self.request.headers.get(header_name, "")
user_persistent_hash = self.request.headers.get("persistent-hash", "")
user_pairwise_id = self.request.headers.get("pairwise-id", "")
if remote_user == "":
if user_persistent_hash == "" and user_pairwise_id == "":
self.welcome_page()
else:
user = self.user_from_username(remote_user)
# Rename old user names using persistent hash to pairwise-id names
# TODO: remove once all users use new pairwise-id name
# Only possible as soon as user-lifecycle has been activated.
user = self.find_user(user_persistent_hash)
if user is not None:
user.name = user_pairwise_id
user.db.commit()
self.log.info("Renamed old persistent-hash user '%s' to '%s'", user_persistent_hash, user_pairwise_id)
# TODO END
user = self.user_from_username(user_pairwise_id)
self.set_login_cookie(user)
next_url = self.get_next_url(user)
......@@ -46,10 +57,6 @@ class RemoteUserAuthenticator(Authenticator):
"""
Accept the authenticated user name from the REMOTE_USER HTTP header.
"""
header_name = Unicode(
default_value='REMOTE_USER',
config=True,
help="""HTTP header to inspect for the authenticated username.""")
def get_handlers(self, app):
return [
......@@ -57,7 +64,7 @@ class RemoteUserAuthenticator(Authenticator):
]
def login_url(self, base_url):
return self.domain + '/Shibboleth.sso/Login
return self.domain + '/Shibboleth.sso/Login'
def logout_url(self, base_url):
return self.domain + '/Shibboleth.sso/Logout?return=/'
......@@ -73,10 +80,6 @@ class RemoteUserLocalAuthenticator(LocalAuthenticator):
Derived from LocalAuthenticator for use of features such as adding
local accounts through the admin interface.
"""
header_name = Unicode(
default_value='REMOTE_USER',
config=True,
help="""HTTP header to inspect for the authenticated username.""")
def get_handlers(self, app):
return [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment