dbo

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HintChars = (keyIDSize * 6 / 4) - 1 //nolint:gomnd
)

Variables

View Source
var ErrKeySize = errors.New("key size invalid")

Functions

This section is empty.

Types

type Header struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Headers

type Headers []Header

func (*Headers) Scan

func (headers *Headers) Scan(value any) error

func (Headers) Value

func (headers Headers) Value() (driver.Value, error)

func (Headers) With

func (headers Headers) With(name, value string) Headers

func (Headers) Without

func (headers Headers) Without(name string) Headers

type Key

type Key [keyIDSize + keyDataSize]byte

func NewKey

func NewKey() (Key, error)

func ParseToken

func ParseToken(value string) (key Key, err error)

func (Key) Hash

func (rt Key) Hash() []byte

func (Key) ID

func (rt Key) ID() KeyID

func (Key) Payload

func (rt Key) Payload() []byte

func (Key) String

func (rt Key) String() string

type KeyID

type KeyID [keyIDSize]byte

func (*KeyID) Scan

func (kid *KeyID) Scan(value any) error

func (KeyID) String

func (kid KeyID) String() string

func (KeyID) Value

func (kid KeyID) Value() (driver.Value, error)

type Storage

type Storage interface {
	io.Closer
	GetToken(ctx context.Context, ref TokenRef) (*Token, error)
	FindToken(ctx context.Context, id KeyID) (*Token, error)
	ListTokens(ctx context.Context, user string) ([]*Token, error)
	CreateToken(ctx context.Context, params TokenParams) error
	DeleteToken(ctx context.Context, ref TokenRef) error
	UpdateTokenKey(ctx context.Context, ref TokenRef, key Key) error
	UpdateTokenConfig(ctx context.Context, ref TokenRef, config TokenConfig) error
	UpdateTokensStats(ctx context.Context, stats []TokenStat) error
}

type Token

type Token struct {
	ID           int64     `db:"id"`
	CreatedAt    time.Time `db:"created_at"`
	UpdatedAt    time.Time `db:"updated_at"`
	KeyID        KeyID     `db:"key_id"`
	Hash         []byte    `db:"hash"` // sha-384
	User         string    `db:"user"`
	Label        string    `db:"label"`
	Path         string    `db:"path"`
	Headers      Headers   `db:"headers"`
	Requests     int64     `db:"requests"`
	LastAccessAt time.Time `db:"last_access_at"`
	// contains filtered or unexported fields
}

func (*Token) Hint

func (t *Token) Hint() string

func (*Token) Valid

func (t *Token) Valid(path string, payload []byte) bool

type TokenConfig

type TokenConfig struct {
	Label   string
	Path    string
	Headers Headers
}

type TokenParams

type TokenParams struct {
	User   string
	Config TokenConfig
	Key    Key
}

type TokenRef

type TokenRef struct {
	User string
	ID   int64
}

type TokenStat

type TokenStat struct {
	Token int64
	Last  time.Time
	Hits  int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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