auth

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package auth is the Redis-backed token store (ADR 0005). Tokens are indexed by their secret bearer value so Validate is an O(1) GET on the auth hot path. It implements model.TokenStore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateValue

func GenerateValue() (string, error)

GenerateValue mints a random opaque bearer value (prefix "tr_"). Tokens are secrets, not JWTs — TinyRaven stores them verbatim in Redis (ADR 0005).

Types

type Store

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

Store validates and persists bearer tokens in Redis.

func NewStore

func NewStore(rdb *redis.Client) *Store

NewStore wraps a redis client.

func (*Store) Bootstrap

func (s *Store) Bootstrap(ctx context.Context, value string) error

Bootstrap creates/overwrites the ADMIN token for value, used at startup from config TR_ADMIN_TOKEN to guarantee a working credential exists (ADR 0005).

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, value string) error

Delete removes a token by its bearer value.

func (*Store) DeleteByName

func (s *Store) DeleteByName(ctx context.Context, name string) (bool, error)

DeleteByName removes the token with the given name. Returns false if none matched.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*model.Token, error)

List returns all stored tokens (SCAN over the namespace).

func (*Store) Ping

func (s *Store) Ping(ctx context.Context) error

Ping satisfies model.Pinger for the readiness probe (ADR 0024).

func (*Store) Put

func (s *Store) Put(ctx context.Context, t *model.Token) error

Put writes (or overwrites) a token, indexed by its value. No TTL — tokens live until revoked.

func (*Store) Validate

func (s *Store) Validate(ctx context.Context, value string) (*model.Token, bool, error)

Validate looks a bearer value up by its O(1) key. ok=false (nil error) when the token is unknown — the caller maps that to 403.

Jump to

Keyboard shortcuts

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