Skip to content

Commit 5c15cec

Browse files
Alter how we detect username from a social authenticator (ansible#622)
In playing around with social auths, some of them don't seem to have a way to remap attributes to what we need (like username) but there is a built in function that gets an "ID_KEY". This change will attempt to get the ID_KEY for an authenticator and then fallback to our expected `username`.
1 parent 31c95bb commit 5c15cec

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ansible_base/authentication/utils/authentication.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def check_system_username(uid: str) -> None:
9595

9696

9797
def determine_username_from_uid_social(**kwargs) -> dict:
98-
selected_username = kwargs.get('details', {}).get('username', None)
98+
uid_field = getattr(kwargs.get('backend', None), 'ID_KEY', 'username')
99+
selected_username = kwargs.get('details', {}).get(uid_field, None)
99100
if not selected_username:
100101
raise AuthException(_('Unable to get associated username from: %(details)s') % {'details': kwargs.get("details", None)})
101102

0 commit comments

Comments
 (0)