Skip to content

Commit e5e27d5

Browse files
committed
shorten further
1 parent 0f992d6 commit e5e27d5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

coderd/provisionerkey/provisionerkey.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ import (
1212
"github.com/coder/coder/v2/cryptorand"
1313
)
1414

15+
const (
16+
secretLength = 32
17+
)
18+
1519
func New(organizationID uuid.UUID, name string, tags map[string]string) (database.InsertProvisionerKeyParams, string, error) {
16-
secret, err := cryptorand.String(64)
20+
secret, err := cryptorand.String(secretLength)
1721
if err != nil {
1822
return database.InsertProvisionerKeyParams{}, "", xerrors.Errorf("generate secret: %w", err)
1923
}
@@ -33,8 +37,8 @@ func New(organizationID uuid.UUID, name string, tags map[string]string) (databas
3337
}
3438

3539
func Validate(token string) error {
36-
if len(token) != 64 {
37-
return xerrors.Errorf("must be 64 characters")
40+
if len(token) != secretLength {
41+
return xerrors.Errorf("must be %d characters", secretLength)
3842
}
3943

4044
return nil

0 commit comments

Comments
 (0)