apikeys

package
v0.2.0-rc.24 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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)
	LockRoleBySlug(ctx context.Context, tx postgres.DBTX, orgSlug, apiKeySlug slug.Slug) (slug.Slug, 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