Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
anodos325 committed Oct 8, 2024
1 parent 5e0d148 commit 1c0404f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/middlewared/middlewared/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def __init__(self, user: dict, assurance: AuthenticatorAssuranceLevel | None):

def notify_used(self):
if self.inactivity_timeout:
self.last_used_at = monotonic()
now = monotonic()
if now < self.last_used_at + self.inactivity_timeout:
self.last_used_at = now

def is_valid(self):
if self.assurance and (now := monotonic()) > self.expiry:
Expand Down
4 changes: 4 additions & 0 deletions src/middlewared/middlewared/etc_files/pam_tdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def convert_keys(username, keys) -> PamTdbEntry:
for key in keys:
if key['expires_at'] is None:
expiry = 0
else if key['revoked']:
# Backstop. We filter these out when we etc.generate, but we don't
# want to have an avenue to accidentally insert revoked keys.
continue
else:
expiry = int(key['expires_at'].timestamp())

Expand Down
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async def item_extend(self, item, ctx):
case -1:
# key has been forcibly revoked
item['revoked'] = True
case 0:
case 0 | None:
# zero value indicates never expires
pass
case _:
Expand Down

0 comments on commit 1c0404f

Please sign in to comment.