Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
anodos325 committed Aug 7, 2024
1 parent dff3d06 commit 845c917
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


@pytest.mark.parametrize('cred,expected', [
(None, '.TRUENAS_INTERNAL'),
(None, '.UNAUTHENTICATED'),
(USER_SESSION, 'bob'),
(API_KEY_SESSION, '.TRUENAS_API_KEY:MY_KEY'),
(TOKEN_USER_SESSION, 'bob'),
Expand Down
4 changes: 2 additions & 2 deletions src/middlewared/middlewared/utils/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

# Special values start with dot to ensure they cannot collide with local usernames
# created via APIs
INTERNAL_SESSION = '.TRUENAS_INTERNAL'
API_KEY_PREFIX = '.TRUENAS_API_KEY:'
NODE_SESSION = '.TRUENAS_NODE'
UNAUTHENTICATED = '.UNAUTHENTICATED'
UNKNOWN_SESSION = '.UNKNOWN'


def audit_username_from_session(cred) -> str:
if cred is None:
return INTERNAL_SESSION
return UNAUTHENTICATED

# This works for regular user session and tokens formed on them
if cred.is_user_session:
Expand Down

0 comments on commit 845c917

Please sign in to comment.