Skip to content

chore: shorten provisioner key #14017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
shorten further
  • Loading branch information
f0ssel committed Jul 25, 2024
commit e5e27d5fd75d1650171e5d44df1716df1d1e0c13
10 changes: 7 additions & 3 deletions coderd/provisionerkey/provisionerkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ import (
"github.com/coder/coder/v2/cryptorand"
)

const (
secretLength = 32
)

func New(organizationID uuid.UUID, name string, tags map[string]string) (database.InsertProvisionerKeyParams, string, error) {
secret, err := cryptorand.String(64)
secret, err := cryptorand.String(secretLength)
if err != nil {
return database.InsertProvisionerKeyParams{}, "", xerrors.Errorf("generate secret: %w", err)
}
Expand All @@ -33,8 +37,8 @@ func New(organizationID uuid.UUID, name string, tags map[string]string) (databas
}

func Validate(token string) error {
if len(token) != 64 {
return xerrors.Errorf("must be 64 characters")
if len(token) != secretLength {
return xerrors.Errorf("must be %d characters", secretLength)
}

return nil
Expand Down
Loading