mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-05-10 01:48:22 +00:00
Setup update to gopenpgp v3
This commit is contained in:
parent
53a858f817
commit
cca7de6c07
1 changed files with 18 additions and 8 deletions
|
@ -6,9 +6,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/passbolt/go-passbolt/api"
|
"github.com/passbolt/go-passbolt/api"
|
||||||
|
|
||||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
|
||||||
"github.com/ProtonMail/gopenpgp/v2/helper"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParseInviteUrl Parses a Passbolt Invite URL into a user id and token
|
// ParseInviteUrl Parses a Passbolt Invite URL into a user id and token
|
||||||
|
@ -31,21 +28,34 @@ func SetupAccount(ctx context.Context, c *api.Client, userID, token, password st
|
||||||
|
|
||||||
keyName := install.Profile.FirstName + " " + install.Profile.LastName + " " + install.Username
|
keyName := install.Profile.FirstName + " " + install.Profile.LastName + " " + install.Username
|
||||||
|
|
||||||
privateKey, err := helper.GenerateKey(keyName, install.Username, []byte(password), "rsa", 4096)
|
pgp := c.GetPGPHandle()
|
||||||
|
|
||||||
|
keyHandler := pgp.KeyGeneration().AddUserId(keyName, install.Username).New()
|
||||||
|
|
||||||
|
key, err := keyHandler.GenerateKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Generating Private Key: %w", err)
|
return "", fmt.Errorf("Generating Private Key: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
key, err := crypto.NewKeyFromArmoredReader(strings.NewReader(privateKey))
|
defer key.ClearPrivateParams()
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("Reading Private Key: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
publicKey, err := key.GetArmoredPublicKey()
|
publicKey, err := key.GetArmoredPublicKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Get Public Key: %w", err)
|
return "", fmt.Errorf("Get Public Key: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lockedKey, err := pgp.LockKey(key, []byte(password))
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("Locking Private Key: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer lockedKey.ClearPrivateParams()
|
||||||
|
|
||||||
|
privateKey, err := lockedKey.Armor()
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("Get Private Key: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
request := api.SetupCompleteRequest{
|
request := api.SetupCompleteRequest{
|
||||||
AuthenticationToken: api.AuthenticationToken{
|
AuthenticationToken: api.AuthenticationToken{
|
||||||
Token: token,
|
Token: token,
|
||||||
|
|
Loading…
Add table
Reference in a new issue