feat: Add TOTP-enabled flag

This commit is contained in:
James Houlahan
2022-12-05 11:32:48 +01:00
committed by James
parent 03e15d19f9
commit 586c991f0e
4 changed files with 10 additions and 11 deletions

View File

@@ -41,25 +41,26 @@ type Auth struct {
}
type RegisteredKey struct {
Version string
KeyHandle string
AttestationFormat string
CredentialID []int
Name string
}
type U2FInfo struct {
Challenge string
RegisteredKeys []RegisteredKey
type FIDO2Info struct {
AuthenticationOptions any
RegisteredKeys []RegisteredKey
}
type TwoFAInfo struct {
Enabled TwoFAStatus
U2F U2FInfo
FIDO2 FIDO2Info
}
type TwoFAStatus int
const (
TwoFADisabled TwoFAStatus = iota
TOTPEnabled
HasTOTP TwoFAStatus = 1 << iota
HasFIDO2
)
type PasswordMode int

View File

@@ -63,7 +63,7 @@ func ExampleManager_NewClientWithLogin() {
defer c.Close()
// If 2FA is necessary, an additional request is required.
if auth.TwoFA.Enabled == proton.TOTPEnabled {
if auth.TwoFA.Enabled&proton.HasTOTP != 0 {
if err := c.Auth2FA(ctx, proton.Auth2FAReq{TwoFactorCode: "...TOTP..."}); err != nil {
panic(err)
}

View File

@@ -34,7 +34,6 @@ func (b *Backend) NewAuthInfo(username string) (proton.AuthInfo, error) {
ServerEphemeral: base64.StdEncoding.EncodeToString(challenge),
Salt: base64.StdEncoding.EncodeToString(acc.salt),
SRPSession: session,
TwoFA: proton.TwoFAInfo{Enabled: proton.TwoFADisabled},
}, nil
})
}

View File

@@ -60,7 +60,6 @@ func (auth *auth) toAuth(userID, authUID string, proof []byte) proton.Auth {
RefreshToken: auth.ref,
ServerProof: base64.StdEncoding.EncodeToString(proof),
TwoFA: proton.TwoFAInfo{Enabled: proton.TwoFADisabled},
PasswordMode: proton.OnePasswordMode,
}
}