Skip to content

Commit

Permalink
AAP-36845 Fix how we build AuthExceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
john-westcott-iv committed Dec 4, 2024
1 parent b309891 commit 1bb9f06
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ansible_base/authentication/utils/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def check_system_username(uid: str) -> None:
"""
if uid.casefold() == settings.SYSTEM_USERNAME.casefold():
logger.warning(f'{settings.SYSTEM_USERNAME} cannot log in from an authenticator!')
raise AuthException(_('System user is not allowed to log in from external authentication sources.'))
raise AuthException(None, _('System user is not allowed to log in from external authentication sources.'))


def determine_username_from_uid_social(**kwargs) -> dict:
Expand All @@ -101,12 +101,13 @@ def determine_username_from_uid_social(**kwargs) -> dict:
selected_username = kwargs.get('details', {}).get(uid_field, None)
if not selected_username:
raise AuthException(
_('Unable to get associated username from attribute {uid_field}: %(details)s') % {'uid_field': uid_field, 'details': kwargs.get("details", None)}
None,
_('Unable to get associated username from attribute {uid_field}: %(details)s') % {'uid_field': uid_field, 'details': kwargs.get("details", None)},
)

authenticator = kwargs.get('backend')
if not authenticator:
raise AuthException(_('Unable to get backend from kwargs'))
raise AuthException(None, _('Unable to get backend from kwargs'))

alt_uid = authenticator.get_alternative_uid(**kwargs)

Expand Down

0 comments on commit 1bb9f06

Please sign in to comment.