mirror of
https://github.com/netbirdio/netbird.git
synced 2025-05-30 06:40:15 +02:00
fix PAT array split
This commit is contained in:
parent
453643683d
commit
628a201e31
@ -1127,8 +1127,8 @@ func (am *DefaultAccountManager) GetAccountFromPAT(token string) (*Account, *Use
|
|||||||
if prefix != PATPrefix {
|
if prefix != PATPrefix {
|
||||||
return nil, nil, fmt.Errorf("token invalid")
|
return nil, nil, fmt.Errorf("token invalid")
|
||||||
}
|
}
|
||||||
secret := token[len(PATPrefix):len(PATPrefix)]
|
secret := token[len(PATPrefix) : len(PATPrefix)+PATsecretLength]
|
||||||
encodedChecksum := token[34:40]
|
encodedChecksum := token[len(PATPrefix)+PATsecretLength : len(PATPrefix)+PATsecretLength+PATChecksumLength]
|
||||||
|
|
||||||
verificationChecksum, err := base62.Decode(encodedChecksum)
|
verificationChecksum, err := base62.Decode(encodedChecksum)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -14,8 +14,9 @@ import (
|
|||||||
const (
|
const (
|
||||||
// PATPrefix is the globally used, 4 char prefix for personal access tokens
|
// PATPrefix is the globally used, 4 char prefix for personal access tokens
|
||||||
PATPrefix = "nbp_"
|
PATPrefix = "nbp_"
|
||||||
secretLength = 30
|
PATsecretLength = 30
|
||||||
PATLength = 40
|
PATLength = 40
|
||||||
|
PATChecksumLength = 6
|
||||||
)
|
)
|
||||||
|
|
||||||
// PersonalAccessToken holds all information about a PAT including a hashed version of it for verification
|
// PersonalAccessToken holds all information about a PAT including a hashed version of it for verification
|
||||||
@ -50,7 +51,7 @@ func CreateNewPAT(description string, expirationInDays int, createdBy string) (*
|
|||||||
}
|
}
|
||||||
|
|
||||||
func generateNewToken() (string, string, error) {
|
func generateNewToken() (string, string, error) {
|
||||||
secret, err := b.Random(secretLength)
|
secret, err := b.Random(PATsecretLength)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user