usertoken

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const InternalTokenHeader = "X-OpenLinker-Internal-Token"

Variables

View Source
var ErrInvalidToken = errors.New("invalid user token")

Functions

This section is empty.

Types

type CLILoginHandler added in v0.1.62

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

CLILoginHandler owns platform client authorization only. The browser approves a narrow User Token; it never hands its JWT or a Runtime credential to the CLI.

func NewCLILoginHandler added in v0.1.62

func NewCLILoginHandler(svc *Service, frontend string, trustedProxies ...*net.IPNet) *CLILoginHandler

func (*CLILoginHandler) Decide added in v0.1.62

func (h *CLILoginHandler) Decide(c echo.Context) error

func (*CLILoginHandler) Exchange added in v0.1.62

func (h *CLILoginHandler) Exchange(c echo.Context) error

func (*CLILoginHandler) Inspect added in v0.1.62

func (h *CLILoginHandler) Inspect(c echo.Context) error

func (*CLILoginHandler) Logout added in v0.1.62

func (h *CLILoginHandler) Logout(c echo.Context) error

func (*CLILoginHandler) Register added in v0.1.62

func (h *CLILoginHandler) Register(api *echo.Group, jwt echo.MiddlewareFunc)

func (*CLILoginHandler) Session added in v0.1.62

func (h *CLILoginHandler) Session(c echo.Context) error

func (*CLILoginHandler) Start added in v0.1.62

func (h *CLILoginHandler) Start(c echo.Context) error

type CreateRequest

type CreateRequest struct {
	Name      string         `json:"name"`
	Grants    []GrantRequest `json:"grants"`
	Scopes    []string       `json:"scopes,omitempty"`
	ExpiresAt *time.Time     `json:"expires_at"`
}

type GrantRequest

type GrantRequest struct {
	Permission   string         `json:"permission"`
	ResourceType string         `json:"resource_type"`
	ResourceID   *string        `json:"resource_id,omitempty"`
	Constraints  map[string]any `json:"constraints,omitempty"`
}

type GrantResponse

type GrantResponse struct {
	Permission   string         `json:"permission"`
	ResourceType string         `json:"resource_type"`
	ResourceID   *string        `json:"resource_id,omitempty"`
	Constraints  map[string]any `json:"constraints"`
}

type Handler

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

func NewHandler

func NewHandler(svc tokenService) *Handler

func (*Handler) Create

func (h *Handler) Create(c echo.Context) error

func (*Handler) Get

func (h *Handler) Get(c echo.Context) error

func (*Handler) List

func (h *Handler) List(c echo.Context) error

func (*Handler) Register

func (h *Handler) Register(api *echo.Group, jwtMiddleware echo.MiddlewareFunc)

Register deliberately uses the JWT middleware, never HybridAuthMiddleware. Handler methods repeat the method check as defense in depth.

func (*Handler) Revoke

func (h *Handler) Revoke(c echo.Context) error

func (*Handler) Update

func (h *Handler) Update(c echo.Context) error

type IntrospectionHandler

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

func NewIntrospectionHandler

func NewIntrospectionHandler(svc interface {
	Introspect(context.Context, string) IntrospectionResponse
}, internalSecret string) *IntrospectionHandler

func (*IntrospectionHandler) Introspect

func (h *IntrospectionHandler) Introspect(c echo.Context) error

func (*IntrospectionHandler) Register

func (h *IntrospectionHandler) Register(e *echo.Echo)

type IntrospectionRequest

type IntrospectionRequest struct {
	Token string `json:"token"`
}

type IntrospectionResponse

type IntrospectionResponse struct {
	Active           bool            `json:"active"`
	IssuerInstanceID string          `json:"issuer_instance_id,omitempty"`
	TokenID          string          `json:"token_id,omitempty"`
	UserID           string          `json:"user_id,omitempty"`
	Permissions      []string        `json:"permissions,omitempty"`
	Grants           []GrantResponse `json:"grants,omitempty"`
	ExpiresAt        *string         `json:"expires_at,omitempty"`
}

type ListOptions

type ListOptions struct {
	Limit   int32
	Offset  int32
	SortBy  string
	SortDir string
	Status  string
	Query   string
}

type ListResponse

type ListResponse struct {
	Items   []TokenResponse `json:"items"`
	Total   int32           `json:"total"`
	Limit   int32           `json:"limit"`
	Offset  int32           `json:"offset"`
	SortBy  string          `json:"sort_by"`
	SortDir string          `json:"sort_dir"`
	HasMore bool            `json:"has_more"`
}

type Service

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

func NewService

func NewService(pool *pgxpool.Pool) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, userID uuid.UUID, req *CreateRequest) (*TokenResponse, error)

func (*Service) Get

func (s *Service) Get(ctx context.Context, userID, tokenID uuid.UUID) (*TokenResponse, error)

func (*Service) Introspect

func (s *Service) Introspect(ctx context.Context, plaintext string) IntrospectionResponse

func (*Service) List

func (s *Service) List(ctx context.Context, userID uuid.UUID, opts ListOptions) (*ListResponse, error)

func (*Service) Revoke

func (s *Service) Revoke(ctx context.Context, userID, tokenID uuid.UUID) error

func (*Service) Update

func (s *Service) Update(ctx context.Context, userID, tokenID uuid.UUID, req *UpdateRequest) (*TokenResponse, error)

func (*Service) Verify

func (s *Service) Verify(ctx context.Context, plaintext string) (uuid.UUID, []string, error)

Verify keeps the one-release verifier interface compatible while all new authorization reads the structured principal from VerifyPrincipal.

func (*Service) VerifyPrincipal

func (s *Service) VerifyPrincipal(ctx context.Context, plaintext string) (*auth.AuthPrincipal, error)

type TokenResponse

type TokenResponse struct {
	ID               string          `json:"id"`
	UserID           string          `json:"user_id"`
	IssuerInstanceID string          `json:"issuer_instance_id"`
	Name             string          `json:"name"`
	Prefix           string          `json:"prefix"`
	Grants           []GrantResponse `json:"grants"`
	Scopes           []string        `json:"scopes"`
	ExpiresAt        *string         `json:"expires_at"`
	LastUsedAt       *string         `json:"last_used_at"`
	RevokedAt        *string         `json:"revoked_at"`
	CreatedAt        string          `json:"created_at"`
	UpdatedAt        string          `json:"updated_at"`
	PlaintextToken   string          `json:"plaintext_token,omitempty"`
}

type UpdateRequest

type UpdateRequest struct {
	Name      *string         `json:"name,omitempty"`
	Grants    *[]GrantRequest `json:"grants,omitempty"`
	Scopes    *[]string       `json:"scopes,omitempty"`
	ExpiresAt *time.Time      `json:"expires_at,omitempty"`
}

Jump to

Keyboard shortcuts

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