pats

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

Functions

This section is empty.

Types

type CreateParams

type CreateParams struct {
	UserSlug                      slug.Slug
	Slug                          slug.Slug
	Name                          string
	Description                   *string
	TokenHash                     string
	TokenPrefix                   string
	ExpiresAt                     *time.Time
	CanManagePersonalAccessTokens bool
}

type PersonalAccessToken

type PersonalAccessToken struct {
	ID                            int
	Slug                          slug.Slug
	Name                          string
	Description                   *string
	TokenPrefix                   string
	UserSlug                      slug.Slug
	CanManagePersonalAccessTokens bool
	ExpiresAt                     *time.Time
	RevokedAt                     *time.Time
	LastUsedAt                    *time.Time
	CreatedAt                     time.Time
	UpdatedAt                     time.Time
}

type Principal

type Principal struct {
	TokenSlug                     slug.Slug
	UserSlug                      slug.Slug
	CanManagePersonalAccessTokens bool
}

type Repository

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

func NewRepository

func NewRepository() Repository

type RotateParams

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

type UpdateParams

type UpdateParams struct {
	UserSlug                         slug.Slug
	Slug                             slug.Slug
	Name                             string
	DescriptionSet                   bool
	Description                      *string
	ExpiresAtSet                     bool
	ExpiresAt                        *time.Time
	CanManagePersonalAccessTokensSet bool
	CanManagePersonalAccessTokens    bool
}

Jump to

Keyboard shortcuts

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