apikeys

package
v0.0.0-...-5106b98 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound          = xerror.NotFound(xerror.APIKey)
	ErrSlugAlreadyExists = xerror.AlreadyExists(xerror.APIKey)
)

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	ID                int
	Slug              slug.Slug
	Name              string
	Description       *string
	TokenPrefix       string
	RoleSlug          slug.Slug
	CanManageAPIKeys  bool
	CreatedByUserSlug *slug.Slug
	ExpiresAt         *time.Time
	RevokedAt         *time.Time
	LastUsedAt        *time.Time
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

type CreateParams

type CreateParams struct {
	OrgSlug           slug.Slug
	Slug              slug.Slug
	Name              string
	Description       *string
	TokenHash         string
	TokenPrefix       string
	CreatedByUserSlug *slug.Slug
	RoleSlug          slug.Slug
	ExpiresAt         *time.Time
	CanManageAPIKeys  bool
}

type Principal

type Principal struct {
	Slug             slug.Slug
	OrgSlug          slug.Slug
	Role             slug.Slug
	CanManageAPIKeys bool
}

type Repository

type Repository interface {
	Create(ctx context.Context, tx postgres.DBTX, params CreateParams) (*APIKey, error)
	FindBySlug(ctx context.Context, tx postgres.DBTX, orgSlug, apiKeySlug slug.Slug) (*APIKey, error)
	ListByOrganization(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug slug.Slug,
		roleFilter *slug.Slug,
		req model.ListRequest,
	) ([]*APIKey, error)
	Update(ctx context.Context, tx postgres.DBTX, params UpdateParams) error
	Revoke(ctx context.Context, tx postgres.DBTX, orgSlug, apiKeySlug slug.Slug) error
	DeleteRevoked(ctx context.Context, tx postgres.DBTX, orgSlug, apiKeySlug slug.Slug) error
	Rotate(ctx context.Context, tx postgres.DBTX, params RotateParams) (*APIKey, error)
	FindActivePrincipalByTokenHash(ctx context.Context, tx postgres.DBTX, tokenHash string) (*Principal, error)
	MarkUsed(ctx context.Context, tx postgres.DBTX, orgSlug, apiKeySlug slug.Slug) error
}

func NewRepository

func NewRepository() Repository

type RotateParams

type RotateParams struct {
	OrgSlug     slug.Slug
	Slug        slug.Slug
	TokenHash   string
	TokenPrefix string
}

type UpdateParams

type UpdateParams struct {
	OrgSlug             slug.Slug
	Slug                slug.Slug
	Name                string
	Description         *string
	ExpiresAt           *time.Time
	CanManageAPIKeysSet bool
	CanManageAPIKeys    bool
}

Jump to

Keyboard shortcuts

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