Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AAP-37017 Fix how we build AuthExceptions #664

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading