inmem

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package inmem is an in-memory adminauth.Store for tests and for the reference server's development mode.

Why

Every adminauth backend runs the same contract suite, and the in-memory one is what the unit tests use so they need no database. It is also what the reference server falls back to when it is configured with in-memory storage, where principals and policies live only as long as the process.

Nothing here is sealed at rest: process memory is inside the trust boundary, and the store holds token digests rather than tokens, so there is no plaintext credential to protect. The same reasoning kept storage/inmem unencrypted in record 0013.

References

  • Decision record: docs/research/decisions/0034-admin-api-and-authorization.md
  • Plan of record: docs/research/implementation_plan.md (phase 8)
  • Contract suite: adminauth/adminauthtest

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store keeps principals and policies in memory. It is safe for concurrent use.

func New

func New() *Store

New returns an empty Store.

func (*Store) CountRoot

func (s *Store) CountRoot(_ context.Context) (int, error)

CountRoot implements adminauth.Store.

func (*Store) CreatePrincipal

func (s *Store) CreatePrincipal(_ context.Context, p adminauth.Principal, digest string, now time.Time) (adminauth.Principal, error)

CreatePrincipal implements adminauth.Store.

func (*Store) DeletePolicy

func (s *Store) DeletePolicy(_ context.Context, name string) error

DeletePolicy implements adminauth.Store.

func (*Store) DeletePrincipal

func (s *Store) DeletePrincipal(_ context.Context, name string) error

DeletePrincipal implements adminauth.Store.

func (*Store) GetPolicy

func (s *Store) GetPolicy(_ context.Context, name string) (adminauth.Policy, error)

GetPolicy implements adminauth.Store.

func (*Store) Policies

func (s *Store) Policies(_ context.Context) ([]adminauth.Policy, error)

Policies implements adminauth.Store, ordered by name.

func (*Store) PolicyVersion

func (s *Store) PolicyVersion(_ context.Context) (int64, error)

PolicyVersion implements adminauth.Store.

func (*Store) Principal

func (s *Store) Principal(_ context.Context, name string) (adminauth.Principal, error)

Principal implements adminauth.Store.

func (*Store) PrincipalByDigest

func (s *Store) PrincipalByDigest(_ context.Context, digest string) (adminauth.Principal, error)

PrincipalByDigest implements adminauth.Store.

func (*Store) Principals

Principals implements adminauth.Store, paging by name.

func (*Store) PutPolicy

func (s *Store) PutPolicy(_ context.Context, p adminauth.Policy, now time.Time) (adminauth.Policy, error)

PutPolicy implements adminauth.Store.

func (*Store) RevokeToken

func (s *Store) RevokeToken(_ context.Context, name string, now time.Time) error

RevokeToken implements adminauth.Store.

func (*Store) SetToken

func (s *Store) SetToken(_ context.Context, name, digest, tokenID string, expires, now time.Time) (adminauth.Principal, error)

SetToken implements adminauth.Store.

func (*Store) UpdatePrincipal

func (s *Store) UpdatePrincipal(_ context.Context, name string, roles []string, root bool, now time.Time) (adminauth.Principal, error)

UpdatePrincipal implements adminauth.Store.

Jump to

Keyboard shortcuts

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