memstore

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package memstore provides in-memory reference implementations of every store interface in the library. They are safe for concurrent use, lose all data on restart, and are intended for tests, demos and as a template for real stores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Invites

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

Invites implements invite.Store.

func NewInvites

func NewInvites() *Invites

NewInvites returns an empty invite store.

func (*Invites) Consume

func (m *Invites) Consume(_ context.Context, hash []byte, usedBy string, at time.Time) (*invite.Invite, error)

Consume implements invite.Store.

func (*Invites) Create

func (m *Invites) Create(_ context.Context, inv *invite.Invite) error

Create implements invite.Store.

func (*Invites) Delete

func (m *Invites) Delete(_ context.Context, id string) error

Delete implements invite.Store.

func (*Invites) DeleteUsable added in v2.4.0

func (m *Invites) DeleteUsable(_ context.Context, id string, now time.Time) error

DeleteUsable implements invite.Manager.

func (*Invites) GetByTokenHash

func (m *Invites) GetByTokenHash(_ context.Context, hash []byte) (*invite.Invite, error)

GetByTokenHash implements invite.Store.

func (*Invites) ListUsable added in v2.4.0

func (m *Invites) ListUsable(_ context.Context, now time.Time) ([]*invite.Invite, error)

ListUsable implements invite.Manager.

func (*Invites) Replace added in v2.4.0

func (m *Invites) Replace(_ context.Context, oldID string, now time.Time, inv *invite.Invite) error

Replace implements invite.Manager.

type MFA added in v2.2.0

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

MFA implements mfa.Store.

func NewMFA added in v2.2.0

func NewMFA() *MFA

NewMFA returns an empty MFA store.

func (*MFA) AdvanceTOTP added in v2.2.0

func (m *MFA) AdvanceTOTP(_ context.Context, subjectID string, step int64) (bool, error)

AdvanceTOTP implements mfa.Store.

func (*MFA) DeleteTOTP added in v2.2.0

func (m *MFA) DeleteTOTP(_ context.Context, subjectID string) error

DeleteTOTP implements mfa.Store.

func (*MFA) GetTOTP added in v2.2.0

func (m *MFA) GetTOTP(_ context.Context, subjectID string) (*mfa.TOTP, error)

GetTOTP implements mfa.Store.

func (*MFA) PutTOTP added in v2.2.0

func (m *MFA) PutTOTP(_ context.Context, t *mfa.TOTP) error

PutTOTP implements mfa.Store.

func (*MFA) UseRecoveryCode added in v2.2.0

func (m *MFA) UseRecoveryCode(_ context.Context, subjectID string, hash []byte) (bool, error)

UseRecoveryCode implements mfa.Store.

type Passkeys added in v2.2.0

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

Passkeys implements passkey.Store.

func NewPasskeys added in v2.2.0

func NewPasskeys() *Passkeys

NewPasskeys returns an empty credential store.

func (*Passkeys) Create added in v2.2.0

func (m *Passkeys) Create(_ context.Context, c *passkey.Credential) error

Create implements passkey.Store.

func (*Passkeys) Delete added in v2.2.0

func (m *Passkeys) Delete(_ context.Context, subjectID string, id []byte) error

Delete implements passkey.Store.

func (*Passkeys) Get added in v2.2.0

func (m *Passkeys) Get(_ context.Context, id []byte) (*passkey.Credential, error)

Get implements passkey.Store.

func (*Passkeys) ListBySubject added in v2.2.0

func (m *Passkeys) ListBySubject(_ context.Context, subjectID string) ([]*passkey.Credential, error)

ListBySubject implements passkey.Store.

func (*Passkeys) Touch added in v2.2.0

func (m *Passkeys) Touch(_ context.Context, id []byte, signCount uint32, backupState bool, at time.Time) error

Touch implements passkey.Store.

type Sessions

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

Sessions implements session.Store.

func NewSessions

func NewSessions() *Sessions

NewSessions returns an empty session store.

func (*Sessions) Create

func (m *Sessions) Create(_ context.Context, s *session.Session) error

Create implements session.Store.

func (*Sessions) Delete

func (m *Sessions) Delete(_ context.Context, id string) error

Delete implements session.Store.

func (*Sessions) DeleteBySubject

func (m *Sessions) DeleteBySubject(_ context.Context, subjectID, exceptID string) (int, error)

DeleteBySubject implements session.Store.

func (*Sessions) Get

func (m *Sessions) Get(_ context.Context, id string) (*session.Session, error)

Get implements session.Store.

func (*Sessions) GetByTokenHash

func (m *Sessions) GetByTokenHash(_ context.Context, hash []byte) (*session.Session, session.TokenState, error)

GetByTokenHash implements session.Store.

func (*Sessions) ListBySubject

func (m *Sessions) ListBySubject(_ context.Context, subjectID string) ([]*session.Session, error)

ListBySubject implements session.Store.

func (*Sessions) PurgeExpired

func (m *Sessions) PurgeExpired(now time.Time)

PurgeExpired removes sessions past their absolute expiry.

func (*Sessions) Rotate

func (m *Sessions) Rotate(_ context.Context, id string, oldHash, newHash []byte, at time.Time) error

Rotate implements session.Store.

func (*Sessions) Touch

func (m *Sessions) Touch(_ context.Context, id string, at time.Time) error

Touch implements session.Store.

type Tokens added in v2.2.0

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

Tokens implements onetime.Store.

func NewTokens added in v2.2.0

func NewTokens() *Tokens

NewTokens returns an empty one-time token store.

func (*Tokens) Consume added in v2.2.0

func (m *Tokens) Consume(_ context.Context, hash []byte, purpose onetime.Purpose, at time.Time) (*onetime.Token, error)

Consume implements onetime.Store.

func (*Tokens) Create added in v2.2.0

func (m *Tokens) Create(_ context.Context, t *onetime.Token) error

Create implements onetime.Store.

func (*Tokens) DeleteBySubject added in v2.2.0

func (m *Tokens) DeleteBySubject(_ context.Context, subjectID string, purpose onetime.Purpose) error

DeleteBySubject implements onetime.Store.

func (*Tokens) GetByTokenHash added in v2.2.0

func (m *Tokens) GetByTokenHash(_ context.Context, hash []byte) (*onetime.Token, error)

GetByTokenHash implements onetime.Store.

type Users

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

Users implements iam.SubjectLoader, iam.IdentityStore and password.CredentialStore.

func NewUsers

func NewUsers() *Users

NewUsers returns an empty user store.

func (*Users) CreateCredential

func (u *Users) CreateCredential(_ context.Context, login, encodedHash string) error

CreateCredential implements password.CredentialStore.

func (*Users) CreateSubject

func (u *Users) CreateSubject(_ context.Context, _ provider.Identity, grant iam.SignupGrant) (string, error)

CreateSubject implements iam.IdentityStore. New subjects get a random ID and the roles from the grant.

func (*Users) DeleteCredential

func (u *Users) DeleteCredential(_ context.Context, login string) error

DeleteCredential implements password.CredentialStore.

func (*Users) DeleteSubject added in v2.3.0

func (u *Users) DeleteSubject(_ context.Context, subjectID string) error

DeleteSubject implements iam.SubjectDeleter.

func (*Users) GetCredential

func (u *Users) GetCredential(_ context.Context, login string) (string, error)

GetCredential implements password.CredentialStore.

func (*Users) Identities

func (u *Users) Identities(subjectID string) []provider.Identity

Identities returns the identities linked to a subject, for display.

func (*Users) LinkIdentity

func (u *Users) LinkIdentity(_ context.Context, subjectID string, id provider.Identity) error

LinkIdentity implements iam.IdentityStore.

func (*Users) LoadSubject

func (u *Users) LoadSubject(_ context.Context, subjectID string) (*iam.Subject, error)

LoadSubject implements iam.SubjectLoader.

func (*Users) PutSubject

func (u *Users) PutSubject(s iam.Subject)

PutSubject creates or replaces a subject. It is meant for seeding and for applications changing roles or disabling a subject.

func (*Users) ResolveIdentity

func (u *Users) ResolveIdentity(_ context.Context, prov, providerID string) (string, error)

ResolveIdentity implements iam.IdentityStore.

func (*Users) UnlinkIdentity

func (u *Users) UnlinkIdentity(_ context.Context, subjectID, prov, providerID string) error

UnlinkIdentity implements iam.IdentityStore.

func (*Users) UpdateCredential

func (u *Users) UpdateCredential(_ context.Context, login, encodedHash string) error

UpdateCredential implements password.CredentialStore.

Jump to

Keyboard shortcuts

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