feat(v2): implement user register OTP (#6030)

* feat(v2): implement user register OTP

* feat(v2): implement user verify OTP

* session: retry on permission denied
This commit is contained in:
Tim Möhlmann
2023-06-20 12:36:21 +02:00
committed by GitHub
parent 4eaf3fb21e
commit 09aafb35eb
10 changed files with 1113 additions and 12 deletions

View File

@@ -17,10 +17,17 @@ type OTP struct {
State MFAState
}
type OTPv2 struct {
*ObjectDetails
Secret string
URI string
}
func NewOTPKey(issuer, accountName string, cryptoAlg crypto.EncryptionAlgorithm) (*otp.Key, *crypto.CryptoValue, error) {
key, err := totp.Generate(totp.GenerateOpts{Issuer: issuer, AccountName: accountName})
if err != nil {
return nil, nil, err
return nil, nil, caos_errs.ThrowInternal(err, "TOTP-ieY3o", "Errors.Internal")
}
encryptedSecret, err := crypto.Encrypt([]byte(key.Secret()), cryptoAlg)
if err != nil {