Skip to content

Commit

Permalink
Use URL-safe base64 encoding of state value
Browse files Browse the repository at this point in the history
  • Loading branch information
DasSkelett committed Aug 2, 2022
1 parent 852a528 commit 1266533
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/authnz/authutil/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
"github.com/sirupsen/logrus"
)

// RandomString returns a base64url-encoded string of random data of size bytes
func RandomString(size int) string {
blk := make([]byte, size)
_, err := rand.Read(blk)
if err != nil {
logrus.Fatal(errors.Wrap(err, "failed to make a random string"))
}
return base64.StdEncoding.EncodeToString(blk)
return base64.URLEncoding.EncodeToString(blk)
}

0 comments on commit 1266533

Please sign in to comment.