Skip to content

Commit

Permalink
NAS-130441 / 24.10 / Add auditing for 2fa configuration (#14138)
Browse files Browse the repository at this point in the history
Generate audit trail for changes related to two-factor authentication.
  • Loading branch information
anodos325 authored Aug 6, 2024
1 parent 2519d9d commit 988b829
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/middlewared/middlewared/plugins/account_/2fa.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def translate_username(self, username):

return await self.middleware.call('user.query', [['username', '=', user['pw_name']]], {'get': True})

@accepts(Str('username'))
@accepts(Str('username'), audit='Unset two-factor authentication secret:', audit_extended=lambda username: username)
@returns()
async def unset_2fa_secret(self, username):
"""
Expand Down Expand Up @@ -132,7 +132,12 @@ async def unset_2fa_secret(self, username):
)

@no_authz_required
@api_method(UserRenew2faSecretArgs, UserRenew2faSecretResult)
@api_method(
UserRenew2faSecretArgs,
UserRenew2faSecretResult,
audit='Renew two-factor authentication secret:',
audit_extended=lambda username, options: username
)
@pass_app()
async def renew_2fa_secret(self, app, username, twofactor_options):
"""
Expand Down
3 changes: 2 additions & 1 deletion src/middlewared/middlewared/plugins/auth_/2fa.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ async def two_factor_extend(self, data):
'auth_twofactor_entry', 'auth_twofactor_update',
('rm', {'name': 'id'}),
('attr', {'update': True}),
)
),
audit='Update two-factor authentication service configuration'
)
async def do_update(self, data):
"""
Expand Down

0 comments on commit 988b829

Please sign in to comment.