aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/auth.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-04-10 17:47:43 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-04-10 17:47:43 -0700
commit7022773e8f3decbe80c37fe77962a70932072d1b (patch)
tree8f6b751d0523993e35ae9dcbc4a4c9ee6188357d /python/fatcat_web/auth.py
parent978edc5dc5fe90f705252c44c1291cc6140eeb3a (diff)
parenteffef07fbb8eea5b608d48e6b6bd420ea2c76506 (diff)
downloadfatcat-7022773e8f3decbe80c37fe77962a70932072d1b.tar.gz
fatcat-7022773e8f3decbe80c37fe77962a70932072d1b.zip
Merge branch 'bnewbold-loginpass-orcid'
Diffstat (limited to 'python/fatcat_web/auth.py')
-rw-r--r--python/fatcat_web/auth.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/python/fatcat_web/auth.py b/python/fatcat_web/auth.py
index 44a03f5f..06c8475b 100644
--- a/python/fatcat_web/auth.py
+++ b/python/fatcat_web/auth.py
@@ -54,10 +54,15 @@ def handle_oauth(remote, token, user_info):
# not sure all loginpass backends will set it
if user_info.get('preferred_username'):
preferred_username = user_info['preferred_username']
+ elif 'orcid.org' in iss:
+ # as a special case, prefix ORCiD identifier so it can be used as a
+ # username. If we instead used the human name, we could have
+ # collisions. Not a great user experience either way.
+ preferred_username = 'i' + user_info['sub'].replace('-', '')
else:
preferred_username = user_info['sub']
- params = fatcat_client.AuthOidc(remote.name, user_info['sub'], iss, user_info['preferred_username'])
+ params = fatcat_client.AuthOidc(remote.name, user_info['sub'], iss, preferred_username)
# this call requires admin privs
(resp, http_status, http_headers) = priv_api.auth_oidc_with_http_info(params)
editor = resp.editor