GenerateKey creates a new secure API key
()
| 21 | |
| 22 | // GenerateKey creates a new secure API key |
| 23 | func GenerateKey() (string, error) { |
| 24 | b := make([]byte, 32) |
| 25 | if _, err := rand.Read(b); err != nil { |
| 26 | return "", err |
| 27 | } |
| 28 | return base64.URLEncoding.EncodeToString(b), nil |
| 29 | } |
| 30 | |
| 31 | // NewAPIKey creates a new API key instance |
| 32 | func NewAPIKey(name, ownerID string, scopes []string, expiresAt time.Time) (*APIKey, error) { |
no outgoing calls