infrastructure

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package infrastructure holds the access adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminMiddleware

func AdminMiddleware(authenticator domain.AdminAuthenticator, logger *slog.Logger) func(http.Handler) http.Handler

AdminMiddleware rejects requests that do not carry the admin key as a Bearer credential.

func BearerMiddleware

func BearerMiddleware(authenticator domain.TokenAuthenticator, logger *slog.Logger) func(http.Handler) http.Handler

BearerMiddleware authenticates the Bearer token and passes the principal to next in the context.

func NewAdminHandler

func NewAdminHandler(params domain.AdminHandlerParams) http.Handler

NewAdminHandler returns the admin API, guarded by the admin key.

func NewRedeemHandler

func NewRedeemHandler(redeemer domain.InviteRedeemer, logger *slog.Logger) http.Handler

NewRedeemHandler returns the endpoint that exchanges an Invite credential for a token.

Types

type BcryptHasher

type BcryptHasher struct{}

BcryptHasher is the bcrypt Hasher.

func NewBcryptHasher

func NewBcryptHasher() *BcryptHasher

NewBcryptHasher returns a BcryptHasher at the default cost.

func (*BcryptHasher) Hash

func (*BcryptHasher) Hash(secret string) (string, error)

Hash implements Hasher.

func (*BcryptHasher) Matches

func (*BcryptHasher) Matches(hash, secret string) bool

Matches implements Hasher.

type InviteRepo

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

InviteRepo adapts persistence.AccessInvites to domain.InviteStore.

func NewInviteRepo

func NewInviteRepo(invites *persistence.AccessInvites) *InviteRepo

NewInviteRepo wraps the invites repository.

func (*InviteRepo) Create

func (r *InviteRepo) Create(ctx context.Context, invite domain.StoredInvite) error

Create implements domain.InviteStore.

func (*InviteRepo) Find

Find implements domain.InviteStore.

func (*InviteRepo) Redeem

func (r *InviteRepo) Redeem(ctx context.Context, inviteID string, token domain.StoredToken) error

Redeem implements domain.InviteStore.

type RandomSecret

type RandomSecret struct{}

RandomSecret is the crypto/rand SecretSource.

func NewRandomSecret

func NewRandomSecret() *RandomSecret

NewRandomSecret returns a RandomSecret.

func (*RandomSecret) NewID

func (*RandomSecret) NewID() (string, error)

NewID implements SecretSource.

func (*RandomSecret) NewSecret

func (*RandomSecret) NewSecret() (string, error)

NewSecret implements SecretSource.

type SystemClock

type SystemClock struct{}

SystemClock is the wall-clock Clock.

func NewSystemClock

func NewSystemClock() *SystemClock

NewSystemClock returns a SystemClock.

func (*SystemClock) Now

func (*SystemClock) Now() time.Time

Now implements Clock.

type TokenRepo

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

TokenRepo adapts persistence.AccessTokens to domain.TokenStore.

func NewTokenRepo

func NewTokenRepo(tokens *persistence.AccessTokens) *TokenRepo

NewTokenRepo wraps the tokens repository.

func (*TokenRepo) Delete

func (r *TokenRepo) Delete(ctx context.Context, id string) error

Delete implements domain.TokenStore.

func (*TokenRepo) Find

func (r *TokenRepo) Find(ctx context.Context, id string) (domain.StoredToken, error)

Find implements domain.TokenStore.

func (*TokenRepo) List

func (r *TokenRepo) List(ctx context.Context) ([]domain.Token, error)

List implements domain.TokenStore and never exposes a hash.

func (*TokenRepo) TouchLastUsed

func (r *TokenRepo) TouchLastUsed(ctx context.Context, id string, usedAt time.Time) error

TouchLastUsed implements domain.TokenStore.

Jump to

Keyboard shortcuts

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