Documentation
¶
Overview ¶
Package infrastructure holds the access adapters.
Index ¶
- func AdminMiddleware(authenticator domain.AdminAuthenticator, logger *slog.Logger) func(http.Handler) http.Handler
- func BearerMiddleware(authenticator domain.TokenAuthenticator, logger *slog.Logger) func(http.Handler) http.Handler
- func NewAdminHandler(params domain.AdminHandlerParams) http.Handler
- func NewRedeemHandler(redeemer domain.InviteRedeemer, logger *slog.Logger) http.Handler
- type BcryptHasher
- type InviteRepo
- type RandomSecret
- type SystemClock
- type TokenRepo
- func (r *TokenRepo) Delete(ctx context.Context, id string) error
- func (r *TokenRepo) Find(ctx context.Context, id string) (domain.StoredToken, error)
- func (r *TokenRepo) List(ctx context.Context) ([]domain.Token, error)
- func (r *TokenRepo) TouchLastUsed(ctx context.Context, id string, usedAt time.Time) error
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 ¶
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 ¶
func (r *InviteRepo) Find(ctx context.Context, id string) (domain.StoredInvite, error)
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 (*RandomSecret) NewID ¶
func (*RandomSecret) NewID() (string, error)
NewID implements SecretSource.
func (*RandomSecret) NewSecret ¶
func (*RandomSecret) NewSecret() (string, error)
NewSecret implements SecretSource.
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.