Documentation
¶
Overview ¶
Package adminkey provides functions for generating admin keys for Convex self-hosted backend instances.
This package generates admin keys compatible with the Convex backend's keybroker module. Keys are generated using AES-128-GCM-SIV encryption (RFC 8452) with keys derived using KBKDF-CTR-HMAC-SHA256 (NIST SP 800-108).
Basic Usage ¶
// Generate a new random instance secret
secret, err := adminkey.GenerateSecret()
if err != nil {
log.Fatal(err)
}
// Or parse an existing secret (64-character hex string)
secret, err = adminkey.ParseSecret("4361726e69...")
if err != nil {
log.Fatal(err)
}
// Issue an admin key
key, err := adminkey.IssueAdminKey(secret, "my-instance", 0, false)
if err != nil {
log.Fatal(err)
}
Key Types ¶
The package supports generating three types of keys:
- Standard admin keys: Full access to run queries, mutations, and actions
- Read-only admin keys: Can only run queries
- System keys: Used for internal Convex operations
Compatibility ¶
This implementation is fully compatible with:
- Convex self-hosted backend instances
- The official Rust gen-admin-key tool
- The Convex backend's keybroker module
Package adminkey implements admin key generation for Convex backend instances.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IssueAdminKey ¶
func IssueAdminKey(secret Secret, instanceName string, memberID uint64, isReadOnly bool) (string, error)
IssueAdminKey generates an admin key for the given instance and member ID.
Parameters:
- secret: The 32-byte instance secret
- instanceName: Name of the Convex instance (e.g., "carnitas")
- memberID: Member ID for the admin key (use 0 for generic admin keys)
- isReadOnly: If true, creates a read-only key that can only run queries
Returns the admin key in the format "instance_name|encrypted_part".
func IssueSystemKey ¶
IssueSystemKey generates a system key for the given instance. System keys are used for internal Convex operations.
Parameters:
- secret: The 32-byte instance secret
- instanceName: Name of the Convex instance
Returns the system key in the format "instance_name|encrypted_part".
Types ¶
type Secret ¶
type Secret [32]byte
Secret represents a 32-byte instance secret
func GenerateSecret ¶
GenerateSecret generates a new random 32-byte secret
func ParseSecret ¶
ParseSecret parses a hex-encoded secret string into a Secret