keys

package
v0.77.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const Prefix = "lst_"

Variables

This section is empty.

Functions

func GenerateAPIKey

func GenerateAPIKey(version, key, org, env, region, project string, scopes []string, expiresAt time.Time) (string, string, error)

func GenerateDeterministicAPIKey added in v0.50.0

func GenerateDeterministicAPIKey(version string, signingKey string, opts ...OptionFunc) (string, string, error)

GenerateDeterministicAPIKey generates an API key with a given random string value. Instead of regenerating the random string when encountering base64 padding, it appends digits to the random string until the padding is gone.

func GenerateRandomString added in v0.12.0

func GenerateRandomString(n int) string

GenerateRandomString generates a random alphanumeric string of length n.

func GenerateSignature

func GenerateSignature(payload, password string) string

GenerateSignature signs the API key with the given password using HMAC-SHA256

func VerifySignature

func VerifySignature(payload, providedSignature, password string) bool

VerifySignature verifies the provided API key with the stored signature

Types

type Key

type Key struct {
	Version      string   `json:"v"`
	Token        string   `json:"t"`
	Organization string   `json:"o"`
	Environment  string   `json:"e,omitempty"`
	Region       string   `json:"r"`
	Project      string   `json:"p,omitempty"`
	Scopes       []string `json:"s,omitempty"`
	Expires      int64    `json:"x,omitempty"`
}

func VerifyAPIKey

func VerifyAPIKey(apiKey, password string) (bool, *Key, error)

type OptionFunc added in v0.70.0

type OptionFunc func(kr *keyRequest) error

func WithEnvironment added in v0.70.0

func WithEnvironment(env string) OptionFunc

func WithExpires added in v0.70.0

func WithExpires(expires int64) OptionFunc

func WithOrganization added in v0.70.0

func WithOrganization(org string) OptionFunc

func WithProject added in v0.70.0

func WithProject(project string) OptionFunc

func WithRegion added in v0.70.0

func WithRegion(region string) OptionFunc

func WithScopes added in v0.70.0

func WithScopes(scopes []string) OptionFunc

func WithSigningKey added in v0.70.0

func WithSigningKey(signingKey string) OptionFunc

func WithToken added in v0.70.0

func WithToken(token string) OptionFunc

func WithVersion added in v0.70.0

func WithVersion(version string) OptionFunc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL