diff --git a/config/default.py b/config/default.py index cb70e726..d2486f86 100644 --- a/config/default.py +++ b/config/default.py @@ -27,34 +27,6 @@ TOKEN_AUTH_SECRET_KEY = environ.get('TOKEN_AUTH_SECRET_KEY', default="Shhhh!!! T FRONTEND_AUTH_CALLBACK = environ.get('FRONTEND_AUTH_CALLBACK', default="http://localhost:4200/session") SWAGGER_AUTH_KEY = environ.get('SWAGGER_AUTH_KEY', default="SWAGGER") -#: Default attribute map for single signon. -SSO_LOGIN_URL = '/login' -SSO_ATTRIBUTE_MAP = { - 'Eppn': (False, 'eppn'), # dhf8r@virginia.edu - 'Uid': (True, 'uid'), # dhf8r - 'givenName': (False, 'first_name'), # Daniel - 'Sn': (False, 'last_name'), # Funk - 'affiliation': (False, 'affiliation'), # 'staff@virginia.edu;member@virginia.edu' - 'displayName': (False, 'display_name'), # Daniel Harold Funk - 'title': (False, 'title') # SOFTWARE ENGINEER V -} - -# This what I see coming back: -# X-Remote-Cn: Daniel Harold Funk (dhf8r) -# X-Remote-Sn: Funk -# X-Remote-Givenname: Daniel -# X-Remote-Uid: dhf8r -# Eppn: dhf8r@virginia.edu -# Cn: Daniel Harold Funk (dhf8r) -# Sn: Funk -# Givenname: Daniel -# Uid: dhf8r -# X-Remote-User: dhf8r@virginia.edu -# X-Forwarded-For: 128.143.0.10 -# X-Forwarded-Host: dev.crconnect.uvadcos.io -# X-Forwarded-Server: dev.crconnect.uvadcos.io -# Connection: Keep-Alive - # %s/%i placeholders expected for uva_id and study_id in various calls. PB_BASE_URL = environ.get('PB_BASE_URL', default="http://localhost:5001/pb/") PB_USER_STUDIES_URL = environ.get('PB_USER_STUDIES_URL', default=PB_BASE_URL + "user_studies?uva_id=%s") diff --git a/crc/api/user.py b/crc/api/user.py index 5c9bc108..6924eb27 100644 --- a/crc/api/user.py +++ b/crc/api/user.py @@ -6,7 +6,7 @@ from flask import redirect, g, request from crc import app, db from crc.api.common import ApiError from crc.models.user import UserModel, UserModelSchema -from crc.services.ldap_service import LdapService +from crc.services.ldap_service import LdapService, LdapUserInfo """ .. module:: crc.api.user @@ -32,6 +32,7 @@ def verify_token(token): def get_current_user(): return UserModelSchema().dump(g.user) +@app.route('/login') def sso_login(): # This what I see coming back: # X-Remote-Cn: Daniel Harold Funk (dhf8r) @@ -59,67 +60,48 @@ def sso_login(): redirect = request.args.get('redirect') app.logger.info("SSO_LOGIN: Full URL: " + request.url) app.logger.info("SSO_LOGIN: User Id: " + uid) - app.logger.info("SSO_LOGIN: Will try to redirect to : " + redirect) + app.logger.info("SSO_LOGIN: Will try to redirect to : " + str(redirect)) ldap_service = LdapService() info = ldap_service.user_info(uid) - user = UserModel(uid=uid, email_address=info.email, display_name=info.display_name, - affiliation=info.affiliation, title=info.title) - - # TODO: Get redirect URL from Shibboleth request header - _handle_login(user, redirect) + return _handle_login(info, redirect) @app.route('/sso') def sso(): response = "" response += "

Headers

" - response += str(request.headers) + response += "