mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-20 21:57:29 -06:00
use MustGenerateSecret for backup codes
This commit is contained in:
parent
c5046b59ef
commit
8f874a0ec0
3 changed files with 90 additions and 3 deletions
|
|
@ -31,13 +31,13 @@ import (
|
|||
"time"
|
||||
|
||||
"codeberg.org/gruf/go-byteutil"
|
||||
"github.com/google/uuid"
|
||||
"github.com/pquerna/otp"
|
||||
"github.com/pquerna/otp/totp"
|
||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/util"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ func (p *Processor) TwoFactorEnable(
|
|||
// to show to the user ONCE ONLY.
|
||||
backupsClearText := make([]string, 8)
|
||||
for i := 0; i < 8; i++ {
|
||||
backupsClearText[i] = uuid.NewString()
|
||||
backupsClearText[i] = util.MustGenerateSecret()
|
||||
}
|
||||
|
||||
// Store only the bcrypt-encrypted
|
||||
|
|
@ -215,7 +215,7 @@ func (p *Processor) TwoFactorEnable(
|
|||
user.TwoFactorBackups = make([]string, 8)
|
||||
for i, backup := range backupsClearText {
|
||||
encryptedBackup, err := bcrypt.GenerateFromPassword(
|
||||
[]byte(backup),
|
||||
byteutil.S2B(backup),
|
||||
bcrypt.DefaultCost,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue