supabase-operator/internal/supabase/jwt.go

20 lines
390 B
Go
Raw Normal View History

package supabase
import (
"crypto/rand"
"encoding/hex"
)
func RandomJWTSecret() ([]byte, error) {
jwtSecretBytes := make([]byte, ServiceConfig.JWT.Defaults.SecretLength)
if _, err := rand.Read(jwtSecretBytes); err != nil {
return nil, err
}
jwtSecretHex := make([]byte, hex.EncodedLen(len(jwtSecretBytes)))
hex.Encode(jwtSecretHex, jwtSecretBytes)
return jwtSecretHex, nil
}