From 193fa604750044652ecee0f14da532fed4aa148d Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Mon, 11 Sep 2023 14:14:41 +0200 Subject: [PATCH] Fix totp based 2fa login --- agent/bitwarden/twofactor/twofactor.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/agent/bitwarden/twofactor/twofactor.go b/agent/bitwarden/twofactor/twofactor.go index 1a34de1..699c58f 100644 --- a/agent/bitwarden/twofactor/twofactor.go +++ b/agent/bitwarden/twofactor/twofactor.go @@ -13,12 +13,12 @@ import ( var twofactorLog = logging.GetLogger("Goldwarden", "TwoFactor") func PerformSecondFactor(resp *TwoFactorResponse, cfg *config.Config) (TwoFactorProvider, []byte, error) { - if resp.TwoFactorProviders2[WebAuthn] != nil { + if provider, isInMap := resp.TwoFactorProviders2[WebAuthn]; isInMap { if isFido2Enabled { - chall := resp.TwoFactorProviders2[WebAuthn]["challenge"].(string) + chall := provider["challenge"].(string) var creds []string - for _, credential := range resp.TwoFactorProviders2[WebAuthn]["allowCredentials"].([]interface{}) { + for _, credential := range provider["allowCredentials"].([]interface{}) { publicKey := credential.(map[string]interface{})["id"].(string) creds = append(creds, publicKey) } @@ -32,11 +32,11 @@ func PerformSecondFactor(resp *TwoFactorResponse, cfg *config.Config) (TwoFactor twofactorLog.Warn("WebAuthn is enabled for the account but goldwarden is not compiled with FIDO2 support") } } - if resp.TwoFactorProviders2[Authenticator] != nil { + if _, isInMap := resp.TwoFactorProviders2[Authenticator]; isInMap { token, err := systemauth.GetPassword("Authenticator Second Factor", "Enter your two-factor auth code") return Authenticator, []byte(token), err } - if resp.TwoFactorProviders2[Email] != nil { + if _, isInMap := resp.TwoFactorProviders2[Email]; isInMap { token, err := systemauth.GetPassword("Email Second Factor", "Enter your two-factor auth code") return Email, []byte(token), err }