1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-28 13:15:12 +01:00

[Bug] Skip WebAuthn 2fa event logs during login flow (#1978)

* [Bug] Supress WebAuthn 2fa event logs during login process

* Formatting

* Simplified method call with new paramter input
This commit is contained in:
Vincent Salucci 2022-04-28 16:42:47 -05:00 committed by GitHub
parent a7a45893a3
commit 8b1a6b4ad3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -77,7 +77,7 @@ namespace Bit.Core.Identity
var providers = user.GetTwoFactorProviders(); var providers = user.GetTwoFactorProviders();
providers[TwoFactorProviderType.WebAuthn] = provider; providers[TwoFactorProviderType.WebAuthn] = provider;
user.SetTwoFactorProviders(providers); user.SetTwoFactorProviders(providers);
await userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.WebAuthn); await userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.WebAuthn, logEvent: false);
return options.ToJson(); return options.ToJson();
} }
@ -123,7 +123,7 @@ namespace Bit.Core.Identity
var providers = user.GetTwoFactorProviders(); var providers = user.GetTwoFactorProviders();
providers[TwoFactorProviderType.WebAuthn].MetaData[webAuthCred.Item1] = webAuthCred.Item2; providers[TwoFactorProviderType.WebAuthn].MetaData[webAuthCred.Item1] = webAuthCred.Item2;
user.SetTwoFactorProviders(providers); user.SetTwoFactorProviders(providers);
await userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.WebAuthn); await userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.WebAuthn, logEvent: false);
return res.Status == "ok"; return res.Status == "ok";
} }

View File

@ -43,7 +43,7 @@ namespace Bit.Core.Services
Task<IdentityResult> UpdateKeyAsync(User user, string masterPassword, string key, string privateKey, Task<IdentityResult> UpdateKeyAsync(User user, string masterPassword, string key, string privateKey,
IEnumerable<Cipher> ciphers, IEnumerable<Folder> folders, IEnumerable<Send> sends); IEnumerable<Cipher> ciphers, IEnumerable<Folder> folders, IEnumerable<Send> sends);
Task<IdentityResult> RefreshSecurityStampAsync(User user, string masterPasswordHash); Task<IdentityResult> RefreshSecurityStampAsync(User user, string masterPasswordHash);
Task UpdateTwoFactorProviderAsync(User user, TwoFactorProviderType type, bool setEnabled = true); Task UpdateTwoFactorProviderAsync(User user, TwoFactorProviderType type, bool setEnabled = true, bool logEvent = true);
Task DisableTwoFactorProviderAsync(User user, TwoFactorProviderType type, Task DisableTwoFactorProviderAsync(User user, TwoFactorProviderType type,
IOrganizationService organizationService); IOrganizationService organizationService);
Task<bool> RecoverTwoFactorAsync(string email, string masterPassword, string recoveryCode, Task<bool> RecoverTwoFactorAsync(string email, string masterPassword, string recoveryCode,

View File

@ -879,12 +879,15 @@ namespace Bit.Core.Services
return IdentityResult.Failed(_identityErrorDescriber.PasswordMismatch()); return IdentityResult.Failed(_identityErrorDescriber.PasswordMismatch());
} }
public async Task UpdateTwoFactorProviderAsync(User user, TwoFactorProviderType type, bool setEnabled = true) public async Task UpdateTwoFactorProviderAsync(User user, TwoFactorProviderType type, bool setEnabled = true, bool logEvent = true)
{ {
SetTwoFactorProvider(user, type, setEnabled); SetTwoFactorProvider(user, type, setEnabled);
await SaveUserAsync(user); await SaveUserAsync(user);
if (logEvent)
{
await _eventService.LogUserEventAsync(user.Id, EventType.User_Updated2fa); await _eventService.LogUserEventAsync(user.Id, EventType.User_Updated2fa);
} }
}
public async Task DisableTwoFactorProviderAsync(User user, TwoFactorProviderType type, public async Task DisableTwoFactorProviderAsync(User user, TwoFactorProviderType type,
IOrganizationService organizationService) IOrganizationService organizationService)