apikey

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	ID         string     `json:"id"`
	OrgID      *string    `json:"org_id,omitempty"`
	OwnerID    *string    `json:"owner_id,omitempty"`
	OwnerType  string     `json:"owner_type"`
	KeyPrefix  string     `json:"key_prefix"`
	Name       string     `json:"name"`
	Scopes     []string   `json:"scopes"`
	LastUsedAt *time.Time `json:"last_used_at,omitempty"`
	ExpiresAt  *time.Time `json:"expires_at,omitempty"`
	CreatedAt  time.Time  `json:"created_at"`
}

type CreateAPIKeyRequest

type CreateAPIKeyRequest struct {
	OrgID     *string    `json:"org_id"`
	OwnerID   *string    `json:"owner_id"`
	OwnerType string     `json:"owner_type"` // user, agent, org
	Name      string     `json:"name" validate:"required"`
	Scopes    []string   `json:"scopes"`
	ExpiresAt *time.Time `json:"expires_at"`
}

type CreateAPIKeyResponse

type CreateAPIKeyResponse struct {
	APIKey
	Key string `json:"key"` // returned only once
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(service *Service) *Handler

func (*Handler) Create

func (h *Handler) Create(w http.ResponseWriter, r *http.Request)

func (*Handler) List

func (h *Handler) List(w http.ResponseWriter, r *http.Request)

func (*Handler) Revoke

func (h *Handler) Revoke(w http.ResponseWriter, r *http.Request)

func (*Handler) Routes

func (h *Handler) Routes() chi.Router

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(pool *pgxpool.Pool) *Service

func (*Service) Create

func (*Service) List

func (s *Service) List(ctx context.Context, orgID string, limit, offset int) ([]APIKey, error)

func (*Service) Revoke

func (s *Service) Revoke(ctx context.Context, id string) error

Jump to

Keyboard shortcuts

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