Skip to content

Commit

Permalink
Merge pull request #530 from wolfv/fix_starlette
Browse files Browse the repository at this point in the history
fix compatibility with latest starlette
  • Loading branch information
wolfv authored May 11, 2022
2 parents 59adbfd + f40ab6f commit f094ab2
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions quetz/authentication/pam.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ async def authenticate(
if data is None:
return None

host = None
if request.client:
host = request.client.host

username = data['username']
try:
pamela.authenticate(
Expand All @@ -156,12 +160,7 @@ async def authenticate(
encoding=self.encoding,
)
except pamela.PAMError as e:
logger.warning(
"PAM Authentication failed (%s@%s): %s",
username,
request.client.host,
e,
)
logger.warning(f"PAM Authentication failed ({username}@{host}): {e}")
return None

if self.check_account:
Expand All @@ -170,12 +169,7 @@ async def authenticate(
username, service=self.service, encoding=self.encoding
)
except pamela.PAMError as e:
logger.warning(
"PAM Account Check failed (%s@%s): %s",
username,
request.client.host,
e,
)
logger.warning(f"PAM Account Check failed ({username}@{host}): {e}")
return None

return username
Expand Down

0 comments on commit f094ab2

Please sign in to comment.