interface

AuthStore

type AuthStore interface { // SetPasswordHash replaces a user-controlled password and atomically revokes // every session and API key for that user. SetPasswordHash(context.Context, schema.Collection, string, []byte, bool) error // ChangePasswordHash replaces a password only while its exact stored hash is // the hash verified by the caller. A successful change revokes every session // and API key. Exact hash comparison also fences hard-delete/same-ID // credential recreation because bcrypt salts make each incarnation unique. ChangePasswordHash(context.Context, schema.Collection, string, []byte, []byte) error // UpgradePasswordHash raises the hash work factor after a successful login // without revoking otherwise-valid sessions. The exact-hash compare-and-set // prevents a slow bcrypt upgrade from overwriting a concurrent reset. UpgradePasswordHash(context.Context, schema.Collection, string, []byte, []byte) error FindAuthCredential(context.Context, schema.Collection, string) (AuthCredential, error) RecordFailedLogin( context.Context, schema.StableID, string, time.Time, int, time.Duration, ) (AuthCredential, error) ResetLoginAttempts(context.Context, schema.StableID, string, time.Time) (bool, error) // CreateSession atomically verifies the exact password hash observed by // password authentication before persisting the new bearer session. CreateSession(context.Context, AuthSession, []byte) error RotateSession(context.Context, string, AuthSession, time.Time) error DeleteSession(context.Context, string) error DeleteUserSession(context.Context, schema.StableID, string, string) error DeleteUserSessions(context.Context, schema.StableID, string) error FindSession(context.Context, string, time.Time) (AuthSession, error) ListSessions(context.Context, schema.StableID, string, time.Time) ([]AuthSession, error) CreateAuthToken(context.Context, AuthToken) error ResetPasswordWithToken(context.Context, schema.StableID, string, []byte, time.Time) (string, error) VerifyEmailWithToken(context.Context, schema.StableID, string, time.Time) (string, error) // CreateAPIKey inserts the key only while the authorizing session remains // active. Password replacement serializes through the same credential row // and therefore cannot leave a late-created key behind. CreateAPIKey(context.Context, AuthAPIKey, string, time.Time) error FindAPIKey(context.Context, string, time.Time) (AuthAPIKey, error) TouchAPIKey(context.Context, string, time.Time) error ListAPIKeys(context.Context, schema.StableID, string, time.Time) ([]AuthAPIKey, error) DeleteAPIKey(context.Context, schema.StableID, string, string) error AllowAuthAttempt(context.Context, string, time.Time, time.Duration, int) (bool, error) }

Persistence required by auth-enabled collections.

Source store/store.go:577

SetPasswordHashfunc(context.Context, schema.Collection, string, []byte, bool) error
SetPasswordHash replaces a user-controlled password and atomically revokes every session and API key for that user.
ChangePasswordHashfunc(context.Context, schema.Collection, string, []byte, []byte) error
ChangePasswordHash replaces a password only while its exact stored hash is the hash verified by the caller. A successful change revokes every session and API key. Exact hash comparison also fences hard-delete/same-ID credential recreation because bcrypt salts make each incarnation unique.
UpgradePasswordHashfunc(context.Context, schema.Collection, string, []byte, []byte) error
UpgradePasswordHash raises the hash work factor after a successful login without revoking otherwise-valid sessions. The exact-hash compare-and-set prevents a slow bcrypt upgrade from overwriting a concurrent reset.
FindAuthCredentialfunc(context.Context, schema.Collection, string) (AuthCredential, error)
The FindAuthCredential value.
RecordFailedLoginfunc(context.Context, schema.StableID, string, time.Time, int, time.Duration) (AuthCredential, error)
The RecordFailedLogin value.
ResetLoginAttemptsfunc(context.Context, schema.StableID, string, time.Time) (bool, error)
The ResetLoginAttempts value.
CreateSessionfunc(context.Context, AuthSession, []byte) error
CreateSession atomically verifies the exact password hash observed by password authentication before persisting the new bearer session.
RotateSessionfunc(context.Context, string, AuthSession, time.Time) error
The RotateSession value.
DeleteSessionfunc(context.Context, string) error
The DeleteSession value.
DeleteUserSessionfunc(context.Context, schema.StableID, string, string) error
The DeleteUserSession value.
DeleteUserSessionsfunc(context.Context, schema.StableID, string) error
The DeleteUserSessions value.
FindSessionfunc(context.Context, string, time.Time) (AuthSession, error)
The FindSession value.
ListSessionsfunc(context.Context, schema.StableID, string, time.Time) ([]AuthSession, error)
The ListSessions value.
CreateAuthTokenfunc(context.Context, AuthToken) error
The CreateAuthToken value.
ResetPasswordWithTokenfunc(context.Context, schema.StableID, string, []byte, time.Time) (string, error)
The ResetPasswordWithToken value.
VerifyEmailWithTokenfunc(context.Context, schema.StableID, string, time.Time) (string, error)
The VerifyEmailWithToken value.
CreateAPIKeyfunc(context.Context, AuthAPIKey, string, time.Time) error
CreateAPIKey inserts the key only while the authorizing session remains active. Password replacement serializes through the same credential row and cannot leave a late-created key behind.
FindAPIKeyfunc(context.Context, string, time.Time) (AuthAPIKey, error)
The FindAPIKey value.
TouchAPIKeyfunc(context.Context, string, time.Time) error
The TouchAPIKey value.
ListAPIKeysfunc(context.Context, schema.StableID, string, time.Time) ([]AuthAPIKey, error)
The ListAPIKeys value.
DeleteAPIKeyfunc(context.Context, schema.StableID, string, string) error
The DeleteAPIKey value.
AllowAuthAttemptfunc(context.Context, string, time.Time, time.Duration, int) (bool, error)
The AllowAuthAttempt value.

Implementations must make failed-attempt updates and session rotation atomic across processes. Password hashes and token digests are private state and never enter document values, hooks, manifests, or protocol responses. AuthTransaction and AuthBootstrapTransaction bind credential creation to content transactions.