Documentation
¶
Overview ¶
Package token implements the Internal Token Service.
Package token implements the Internal Token Service.
Index ¶
- type CreateOptions
- type GormService
- func (s *GormService) Create(ctx context.Context, options CreateOptions) (*models.RouterToken, error)
- func (s *GormService) Delete(ctx context.Context, identifier string) error
- func (s *GormService) Get(ctx context.Context, identifier string) (*models.RouterToken, error)
- func (s *GormService) List(ctx context.Context) ([]*models.RouterToken, error)
- func (s *GormService) Regenerate(ctx context.Context, identifier string) (*models.RouterToken, error)
- func (s *GormService) SetLogger(l *slog.Logger)
- func (s *GormService) UpdateRules(ctx context.Context, identifier string, rules models.TokenRules) error
- func (s *GormService) Validate(ctx context.Context, raw string) (*models.RouterToken, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateOptions ¶
type CreateOptions struct {
Name string
Rules models.TokenRules
}
CreateOptions holds the parameters for issuing a new token.
type GormService ¶ added in v0.4.0
type GormService struct {
// contains filtered or unexported fields
}
GormService manages router tokens on the SQLite handle with explicit converters between wire types and join rows. Traditional GORM use: none; every statement runs through gorm.G with typed clauses.
func NewGorm ¶ added in v0.4.0
func NewGorm(database *db.Database) *GormService
NewGorm constructs a GORM-backed token service on the SQLite handle.
func (*GormService) Create ¶ added in v0.4.0
func (s *GormService) Create(ctx context.Context, options CreateOptions) (*models.RouterToken, error)
Create mints a token and persists its base row plus join rows in one transaction. The raw secret returns once and never persists.
func (*GormService) Delete ¶ added in v0.4.0
func (s *GormService) Delete(ctx context.Context, identifier string) error
Delete removes one token. Join rows cascade from the base delete. A zero row delete reports not-found through the WithResult tracker.
func (*GormService) Get ¶ added in v0.4.0
func (s *GormService) Get(ctx context.Context, identifier string) (*models.RouterToken, error)
Get returns one token with rules rebuilt from the join tables.
func (*GormService) List ¶ added in v0.4.0
func (s *GormService) List(ctx context.Context) ([]*models.RouterToken, error)
List returns every token ordered by identifier with rules rebuilt per row.
func (*GormService) Regenerate ¶ added in v0.4.0
func (s *GormService) Regenerate(ctx context.Context, identifier string) (*models.RouterToken, error)
Regenerate replaces the secret while keeping identifier, name, and rules. The single-column Update keeps the hash write minimal.
func (*GormService) SetLogger ¶ added in v0.4.0
func (s *GormService) SetLogger(l *slog.Logger)
SetLogger wires structured logging.
func (*GormService) UpdateRules ¶ added in v0.4.0
func (s *GormService) UpdateRules(ctx context.Context, identifier string, rules models.TokenRules) error
UpdateRules replaces allow flags and every join row in one transaction.
func (*GormService) Validate ¶ added in v0.4.0
func (s *GormService) Validate(ctx context.Context, raw string) (*models.RouterToken, error)
Validate resolves the raw bearer value through the unique token hash index and rebuilds rules from the join tables. Unknown secrets deny with unauthorized, never not-found.