mirror of
https://github.com/netbirdio/netbird.git
synced 2025-04-17 16:08:47 +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 {
|
||||
return nil, nil, fmt.Errorf("token invalid")
|
||||
}
|
||||
secret := token[len(PATPrefix):len(PATPrefix)]
|
||||
encodedChecksum := token[34:40]
|
||||
secret := token[len(PATPrefix) : len(PATPrefix)+PATsecretLength]
|
||||
encodedChecksum := token[len(PATPrefix)+PATsecretLength : len(PATPrefix)+PATsecretLength+PATChecksumLength]
|
||||
|
||||
verificationChecksum, err := base62.Decode(encodedChecksum)
|
||||
if err != nil {
|
||||
|
@ -13,9 +13,10 @@ import (
|
||||
|
||||
const (
|
||||
// PATPrefix is the globally used, 4 char prefix for personal access tokens
|
||||
PATPrefix = "nbp_"
|
||||
secretLength = 30
|
||||
PATLength = 40
|
||||
PATPrefix = "nbp_"
|
||||
PATsecretLength = 30
|
||||
PATLength = 40
|
||||
PATChecksumLength = 6
|
||||
)
|
||||
|
||||
// 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) {
|
||||
secret, err := b.Random(secretLength)
|
||||
secret, err := b.Random(PATsecretLength)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user