mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 20:57:31 +00:00
feat: add otp name and make it configurable (#5631)
* feat: add otp name and make it configurable * feat: use pre-existing otp env var * feat: use requested domain if otp issuer is empty * cleanup --------- Co-authored-by: Sem den Broeder <semnelldenbroeder@gmail.com> Co-authored-by: Elio Bischof <eliobischof@gmail.com> Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:

committed by
GitHub

parent
923f691d77
commit
19f2f83b61
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
@@ -71,11 +72,14 @@ func (c *Commands) AddHumanOTP(ctx context.Context, userID, resourceowner string
|
||||
if accountName == "" {
|
||||
accountName = string(human.EmailAddress)
|
||||
}
|
||||
key, secret, err := domain.NewOTPKey(c.multifactors.OTP.Issuer, accountName, c.multifactors.OTP.CryptoMFA)
|
||||
issuer := c.multifactors.OTP.Issuer
|
||||
if issuer == "" {
|
||||
issuer = authz.GetInstance(ctx).RequestedDomain()
|
||||
}
|
||||
key, secret, err := domain.NewOTPKey(issuer, accountName, c.multifactors.OTP.CryptoMFA)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = c.eventstore.Push(ctx, user.NewHumanOTPAddedEvent(ctx, userAgg, secret))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user