mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-25 19:36:43 +00:00
GODT-1609: Fix bridge password encoding
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package vault
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
||||
)
|
||||
|
||||
@ -16,3 +18,12 @@ func newRandomToken(size int) []byte {
|
||||
|
||||
return token
|
||||
}
|
||||
|
||||
func newRandomString(size int) []byte {
|
||||
token, err := RandomToken(size)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return []byte(hex.EncodeToString(token))
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ func (vault *Vault) ForUser(fn func(*User) error) error {
|
||||
}
|
||||
|
||||
// AddUser creates a new user in the vault with the given ID and username.
|
||||
// A bridge password is generated using the package's token generator.
|
||||
// A bridge password and gluon key are generated using the package's token generator.
|
||||
func (vault *Vault) AddUser(userID, username, authUID, authRef string, keyPass []byte) (*User, error) {
|
||||
if idx := xslices.IndexFunc(vault.get().Users, func(user UserData) bool {
|
||||
return user.UserID == userID
|
||||
@ -107,7 +107,7 @@ func (vault *Vault) AddUser(userID, username, authUID, authRef string, keyPass [
|
||||
GluonKey: newRandomToken(32),
|
||||
GluonIDs: make(map[string]string),
|
||||
UIDValidity: make(map[string]imap.UID),
|
||||
BridgePass: newRandomToken(16),
|
||||
BridgePass: newRandomString(16),
|
||||
AddressMode: CombinedMode,
|
||||
|
||||
AuthUID: authUID,
|
||||
|
||||
Reference in New Issue
Block a user