Documentation
¶
Index ¶
- Constants
- Variables
- func NormalizeEmail(value string) (string, error)
- type Account
- type AccountStore
- type Argon2idConfig
- type Argon2idHasher
- type AuditSink
- type AuditSinkFunc
- type AuthContext
- type AuthTransaction
- type BasicProfile
- type ChangePasswordRequest
- type ClaimsEnricher
- type ClaimsEnricherFunc
- type CommonPasswordChecker
- type CommonPasswordCheckerFunc
- type Config
- type Credential
- type EmailChallengeIssueResult
- type EmailChallengeIssueStatus
- type EmailChallengeLimits
- type EmailChallengePurpose
- type EmailChallengeRecord
- type EmailChallengeStore
- type EmailChallengeVerifyRequest
- type EmailChallengeVerifyResult
- type EmailChallengeVerifyStatus
- type EmailChangeIssueResult
- type EmailChangeIssueStatus
- type EmailChangeRecord
- type EmailChangeStore
- type EmailChangeVerifyRequest
- type EmailChangeVerifyResult
- type EmailChangeVerifyStatus
- type EncryptedEnvelope
- type EncryptedEvent
- type EncryptedEventSink
- type ExternalIdentity
- type ExternalLoginRequest
- type Identifier
- type IdentifierInput
- type IdentifierResolver
- type IdentifierResolverFunc
- type IdentifierScheme
- type IdentityLink
- type IdentityLinkStore
- type Key
- type KeyRing
- type LocalAccountRecord
- type LoginRequest
- type LoginResult
- type MembershipGate
- type MembershipGateFunc
- type Notification
- type NotificationDelivery
- type NotificationDeliveryPolicy
- type NotificationRenderer
- type NotificationRendererFunc
- type NotificationSender
- type NotificationSenderFunc
- type NotificationTransactiondeprecated
- type PasswordChangeStoreRequest
- type PasswordChangeStoreResult
- type PasswordChangeStoreStatus
- type PasswordEmailChangeRequest
- type PasswordHasher
- type PasswordPolicy
- type PasswordResetConsumeRequest
- type PasswordResetConsumeResult
- type PasswordResetConsumeStatus
- type PasswordResetReceipt
- type PasswordResetRecord
- type PasswordResetStore
- type PendingEmailChange
- type RateLimitPolicy
- type RateLimitRequest
- type RateLimitResult
- type RateLimitStore
- type Realm
- type RefreshRotationRequest
- type RefreshRotationResult
- type RefreshRotationStatus
- type RegisterRequest
- type RegisterResult
- type Runtime
- func (r *Runtime) AcknowledgeEncryptedEvent(ctx context.Context, eventID string) error
- func (r *Runtime) AuthenticateSession(ctx context.Context, token string) (AuthContext, error)
- func (r *Runtime) ChangePassword(ctx context.Context, request ChangePasswordRequest) (Account, error)
- func (r *Runtime) CleanupExpiredEncryptedEvents(ctx context.Context) (int64, error)
- func (r *Runtime) ConfirmEmailChange(ctx context.Context, subjectID SubjectID, code string) (Account, error)
- func (r *Runtime) DecryptNotificationEvent(event EncryptedEvent) (Notification, error)
- func (r *Runtime) FindAccount(ctx context.Context, identifier IdentifierInput) (Account, error)
- func (r *Runtime) GetAccount(ctx context.Context, subjectID SubjectID) (Account, error)
- func (r *Runtime) LinkExternalIdentity(ctx context.Context, auth AuthContext, external ExternalIdentity) (IdentityLink, error)
- func (r *Runtime) Login(ctx context.Context, request LoginRequest) (LoginResult, error)
- func (r *Runtime) LoginExternal(ctx context.Context, request ExternalLoginRequest) (LoginResult, error)
- func (r *Runtime) Logout(ctx context.Context, subjectID SubjectID, sessionID string) error
- func (r *Runtime) LogoutAll(ctx context.Context, subjectID SubjectID) (int64, error)
- func (r *Runtime) PendingEmailChange(ctx context.Context, subjectID SubjectID) (PendingEmailChange, error)
- func (r *Runtime) ProvisionTrustedLocalAccount(ctx context.Context, request RegisterRequest) (Account, error)
- func (r *Runtime) Refresh(ctx context.Context, rawRefreshToken string) (TokenPair, error)
- func (r *Runtime) Register(ctx context.Context, request RegisterRequest) (RegisterResult, error)
- func (r *Runtime) RequestEmailChange(ctx context.Context, subjectID SubjectID, newEmail string) error
- func (r *Runtime) RequestEmailChangeWithPassword(ctx context.Context, request PasswordEmailChangeRequest) error
- func (r *Runtime) RequestPasswordReset(ctx context.Context, email string) error
- func (r *Runtime) RequestPasswordResetWithReceipt(ctx context.Context, email string, ...) error
- func (r *Runtime) ResetPassword(ctx context.Context, rawToken, newPassword string) error
- func (r *Runtime) ResolveExternalIdentity(ctx context.Context, external ExternalIdentity) (Account, error)
- func (r *Runtime) SendEmailChallenge(ctx context.Context, subjectID SubjectID, purpose EmailChallengePurpose) error
- func (r *Runtime) SetSubjectStatus(ctx context.Context, subjectID SubjectID, status SubjectStatus) (Subject, error)
- func (r *Runtime) UpdateBasicProfile(ctx context.Context, subjectID SubjectID, profile BasicProfile) (Account, error)
- func (r *Runtime) VerifyAccessToken(ctx context.Context, token string, introspect bool) (AuthContext, error)deprecated
- func (r *Runtime) VerifyCredential(ctx context.Context, credential Credential) (Account, error)
- func (r *Runtime) VerifyEmailChallenge(ctx context.Context, subjectID SubjectID, purpose EmailChallengePurpose, ...) (Account, error)
- func (r *Runtime) VerifyJWT(ctx context.Context, token string) (AuthContext, error)
- type RuntimeStore
- type SSOAccountRecord
- type SecretDigest
- type SecurityEvent
- type SecurityEventType
- type Session
- type SessionRecord
- type SessionScope
- type SessionSecurity
- type SessionStore
- type SigningConfig
- type Subject
- type SubjectID
- func (id SubjectID) IsZero() bool
- func (id SubjectID) MarshalText() ([]byte, error)
- func (id *SubjectID) Scan(source any) error
- func (id SubjectID) String() string
- func (id *SubjectID) UnmarshalText(value []byte) error
- func (id SubjectID) Validate() error
- func (id SubjectID) Value() (driver.Value, error)
- type SubjectStatus
- type TokenPair
- type URLBuilder
- type URLBuilderFunc
Constants ¶
const ( DefaultPasswordMinLength = 8 DefaultPasswordMaxLength = 128 DefaultArgon2MemoryKiB = 19 * 1024 DefaultArgon2Iterations = 2 DefaultArgon2Parallelism = 1 DefaultMaxConcurrentPasswordHashes = 4 )
const (
MaxAccessTokenTTL = 5 * time.Minute
)
Variables ¶
var ( ErrOperationOutcomeUnknown = errors.New("operation commit outcome is unknown") ErrInvalidSubjectID = errors.New("invalid subject ID") ErrInvalidSubjectStatus = errors.New("invalid subject status") ErrInvalidIdentifierScheme = errors.New("invalid identifier scheme") ErrInvalidIdentifier = errors.New("invalid identifier") ErrIdentifierAlreadyExists = errors.New("identifier already exists") ErrInvalidRealm = errors.New("invalid realm") ErrRealmNotRegistered = errors.New("realm is not registered") ErrInvalidChallengePurpose = errors.New("invalid email challenge purpose") ErrAccountNotFound = errors.New("account not found") ErrInvalidCredentials = errors.New("invalid credentials") ErrCurrentPasswordInvalid = errors.New("current password is invalid") ErrPasswordUnchanged = errors.New("new password matches current password") ErrPasswordChangeConflict = errors.New("password changed concurrently") ErrAuthenticationRateLimited = errors.New("authentication rate limited") ErrPasswordHashOverloaded = errors.New("password hashing capacity exhausted") ErrMembershipDenied = errors.New("realm membership denied") ErrEmailVerificationRequired = errors.New("verified email required") ErrInvalidPassword = errors.New("invalid password") ErrCommonPassword = errors.New("common password is not allowed") ErrInvalidToken = errors.New("invalid token") ErrReservedAccessTokenClaim = errors.New("claims enricher set a reserved access-token claim") ErrExpiredToken = errors.New("token expired") ErrRefreshReplay = errors.New("refresh token replay detected") ErrSessionRevoked = errors.New("session revoked") ErrSecurityVersionMismatch = errors.New("security version mismatch") ErrResetAlreadyUsed = errors.New("password reset token already used") ErrInvalidConfirmationCode = errors.New("invalid confirmation code") ErrConfirmationExpired = errors.New("confirmation code expired") ErrConfirmationAttempts = errors.New("confirmation attempts exhausted") ErrConfirmationRateLimited = errors.New("confirmation rate limited") ErrConfirmationResendDelay = errors.New("wait before resending confirmation") ErrEmailChangeNotFound = errors.New("pending email change not found") ErrEmailChangeSameValue = errors.New("new email matches current email") ErrKeyRingInvalid = errors.New("invalid key ring") ErrKeyPurposeCollision = errors.New("cryptographic key reused across purposes") ErrNotificationSinkRequired = errors.New("encrypted notification sink is required") ErrURLBuilderRequired = errors.New("URL builder is required") ErrIdentityLinkNotFound = errors.New("identity link not found") ErrIdentityLinkConflict = errors.New("identity link conflict") ErrExplicitIdentityLink = errors.New("explicit authenticated identity linking is required") )
var ErrNotificationDeliveryDisabled = errors.New("notification delivery is disabled")
ErrPasswordVerificationUnavailable marks an operational failure from a custom PasswordHasher. Wrap or join the underlying cause to preserve diagnostics.
var ErrRateLimitTransactionUnsupported = errors.New("rate-limit admission requires no active auth transaction")
ErrRateLimitTransactionUnsupported means attempt admission was invoked inside a managed auth transaction. Call the rate-limited Runtime operation before opening an outer AuthTransaction; do not strip the callback context to retry. The built-in stores reject this composition before consuming an attempt or verifying a password. This is a wiring error, not a throttling or credential failure. Transactional email-issue quotas are not affected.
var NilSubjectID = SubjectID(uuid.Nil)
Functions ¶
func NormalizeEmail ¶
Types ¶
type Account ¶
type Account struct {
Subject Subject
PrimaryEmail Identifier
Profile BasicProfile
}
func (Account) EmailVerified ¶
type AccountStore ¶
type AccountStore interface {
// LockAccount requires AuthTransaction and locks the canonical subject before dependent state.
LockAccount(ctx context.Context, subjectID SubjectID) (Account, error)
CreateLocalAccount(ctx context.Context, record LocalAccountRecord) (Account, error)
FindAccount(ctx context.Context, identifier IdentifierInput) (Account, error)
FindLocalAccount(ctx context.Context, identifier IdentifierInput) (LocalAccountRecord, error)
GetLocalAccount(ctx context.Context, subjectID SubjectID) (LocalAccountRecord, error)
GetAccount(ctx context.Context, subjectID SubjectID) (Account, error)
UpdateBasicProfile(ctx context.Context, subjectID SubjectID, profile BasicProfile, now time.Time) (Account, error)
ChangePassword(ctx context.Context, request PasswordChangeStoreRequest) (PasswordChangeStoreResult, error)
}
type Argon2idConfig ¶
type Argon2idHasher ¶
type Argon2idHasher struct {
// contains filtered or unexported fields
}
func NewArgon2idHasher ¶
func NewArgon2idHasher(config Argon2idConfig) (*Argon2idHasher, error)
func (*Argon2idHasher) HashPassword ¶
func (h *Argon2idHasher) HashPassword(password string) (string, error)
func (*Argon2idHasher) VerifyPassword ¶
func (h *Argon2idHasher) VerifyPassword(phc, password string) error
type AuditSink ¶
type AuditSink interface {
RecordSecurityEvent(ctx context.Context, event SecurityEvent) error
}
type AuditSinkFunc ¶
type AuditSinkFunc func(context.Context, SecurityEvent) error
func (AuditSinkFunc) RecordSecurityEvent ¶
func (f AuditSinkFunc) RecordSecurityEvent(ctx context.Context, event SecurityEvent) error
type AuthContext ¶
type AuthTransaction ¶ added in v0.5.0
type AuthTransaction interface {
InAuthTransaction(ctx context.Context, fn func(context.Context) error) error
}
AuthTransaction atomically commits all participating auth, audit and encrypted event writes. Callback errors roll back. A failed commit with uncertain server outcome must wrap ErrOperationOutcomeUnknown. Nested auth writes join the same scope. Credential-attempt admission is separate: built-in stores reject TakeRateLimit in this scope with ErrRateLimitTransactionUnsupported. Call rate-limited Runtime operations outside an outer transaction. Hooks must not perform irreversible external actions inside this callback.
type BasicProfile ¶
type ChangePasswordRequest ¶
type ClaimsEnricher ¶
type ClaimsEnricherFunc ¶
func (ClaimsEnricherFunc) EnrichClaims ¶
type CommonPasswordChecker ¶
type CommonPasswordCheckerFunc ¶
func (CommonPasswordCheckerFunc) IsCommonPassword ¶
func (f CommonPasswordCheckerFunc) IsCommonPassword(password string) bool
type Config ¶
type Config struct {
NotificationDelivery NotificationDeliveryPolicy
Store RuntimeStore
Signing SigningConfig
TokenHMACKeys KeyRing
OutboxAEADKeys KeyRing
EventSink EncryptedEventSink
NotificationTransaction NotificationTransaction // Deprecated: use AuthTransaction.
AuthTransaction AuthTransaction
// Nil allows all trusted issuers; empty disables verified-email auto-linking.
AutoLinkVerifiedEmailIssuers []string
// ManagedNotificationDelivery enables typed, lease-owned PostgreSQL delivery.
// A custom transaction alone keeps the configured renderer and event sink.
ManagedNotificationDelivery bool
IdentifierResolvers map[IdentifierScheme]IdentifierResolver
MembershipGate MembershipGate
ClaimsEnricher ClaimsEnricher
NotificationRenderer NotificationRenderer
URLBuilder URLBuilder
AuditSink AuditSink
PasswordHasher PasswordHasher
// Zero defaults to four concurrent hashes/verifications per shared Runtime.
// Excess work fails immediately with ErrPasswordHashOverloaded.
MaxConcurrentPasswordHashes int
PasswordPolicy PasswordPolicy
AdditionalRealms []Realm
AccessTTL time.Duration
SessionTTL time.Duration
RefreshTTL time.Duration
PasswordResetTTL time.Duration
ChallengeTTL time.Duration
EmailChangeTTL time.Duration
EnvelopeRetention time.Duration
ResetResponseFloor time.Duration
IdentityLinkAuthMaxAge time.Duration
LoginRateLimit RateLimitPolicy
PasswordResetRateLimit RateLimitPolicy
Now func() time.Time
Random io.Reader
}
type Credential ¶
type Credential struct {
Identifier IdentifierInput
Password string
}
type EmailChallengeIssueResult ¶
type EmailChallengeIssueResult struct {
Status EmailChallengeIssueStatus
RetryAt time.Time
}
type EmailChallengeIssueStatus ¶
type EmailChallengeIssueStatus string
const ( EmailChallengeIssued EmailChallengeIssueStatus = "issued" EmailChallengeWait EmailChallengeIssueStatus = "wait" EmailChallengeHourlyLimit EmailChallengeIssueStatus = "hourly_limit" EmailChallengeDailyLimit EmailChallengeIssueStatus = "daily_limit" )
type EmailChallengeLimits ¶
type EmailChallengePurpose ¶
type EmailChallengePurpose string
const EmailChallengePurposeVerification EmailChallengePurpose = "verification"
func (EmailChallengePurpose) Validate ¶
func (p EmailChallengePurpose) Validate() error
type EmailChallengeRecord ¶
type EmailChallengeRecord struct {
ID string
SubjectID SubjectID
IdentifierID string
// Runtime supplies these together so a store can reject a challenge if
// the account changes after the caller reads its email destination.
ExpectedNormalizedEmail string
ExpectedSecurityVersion int64
Purpose EmailChallengePurpose
Digest SecretDigest
RateDigest SecretDigest
MaxAttempts int
ExpiresAt time.Time
CreatedAt time.Time
}
type EmailChallengeStore ¶
type EmailChallengeStore interface {
IssueEmailChallenge(
ctx context.Context,
record EmailChallengeRecord,
limits EmailChallengeLimits,
) (EmailChallengeIssueResult, error)
VerifyEmailChallenge(ctx context.Context, request EmailChallengeVerifyRequest) (EmailChallengeVerifyResult, error)
}
type EmailChallengeVerifyRequest ¶
type EmailChallengeVerifyRequest struct {
SubjectID SubjectID
Purpose EmailChallengePurpose
Digests []SecretDigest
Now time.Time
}
type EmailChallengeVerifyResult ¶
type EmailChallengeVerifyResult struct {
Status EmailChallengeVerifyStatus
Account Account
Attempts int
}
type EmailChallengeVerifyStatus ¶
type EmailChallengeVerifyStatus string
const ( EmailChallengeVerified EmailChallengeVerifyStatus = "verified" EmailChallengeInvalid EmailChallengeVerifyStatus = "invalid" EmailChallengeExpired EmailChallengeVerifyStatus = "expired" EmailChallengeAttemptsUsed EmailChallengeVerifyStatus = "attempts_used" EmailChallengeAlreadyVerified EmailChallengeVerifyStatus = "already_verified" )
type EmailChangeIssueResult ¶
type EmailChangeIssueResult struct {
Status EmailChangeIssueStatus
RetryAt time.Time
}
type EmailChangeIssueStatus ¶
type EmailChangeIssueStatus string
const ( EmailChangeIssued EmailChangeIssueStatus = "issued" EmailChangeWait EmailChangeIssueStatus = "wait" EmailChangeHourlyLimit EmailChangeIssueStatus = "hourly_limit" EmailChangeDailyLimit EmailChangeIssueStatus = "daily_limit" EmailChangeSameValue EmailChangeIssueStatus = "same_value" )
type EmailChangeRecord ¶
type EmailChangeStore ¶
type EmailChangeStore interface {
IssueEmailChange(
ctx context.Context,
record EmailChangeRecord,
limits EmailChallengeLimits,
) (EmailChangeIssueResult, error)
GetPendingEmailChange(ctx context.Context, subjectID SubjectID, now time.Time) (PendingEmailChange, error)
VerifyEmailChange(ctx context.Context, request EmailChangeVerifyRequest) (EmailChangeVerifyResult, error)
}
type EmailChangeVerifyRequest ¶
type EmailChangeVerifyRequest struct {
SubjectID SubjectID
Digests []SecretDigest
Now time.Time
}
type EmailChangeVerifyResult ¶
type EmailChangeVerifyResult struct {
Status EmailChangeVerifyStatus
Account Account
Attempts int
}
type EmailChangeVerifyStatus ¶
type EmailChangeVerifyStatus string
const ( EmailChangeVerified EmailChangeVerifyStatus = "verified" EmailChangeInvalid EmailChangeVerifyStatus = "invalid" EmailChangeExpired EmailChangeVerifyStatus = "expired" EmailChangeAttemptsUsed EmailChangeVerifyStatus = "attempts_used" EmailChangeNotFound EmailChangeVerifyStatus = "not_found" )
type EncryptedEnvelope ¶
type EncryptedEvent ¶
type EncryptedEventSink ¶
type ExternalIdentity ¶
type ExternalIdentity struct {
Issuer string
Subject string
Email string
EmailVerified bool
Profile BasicProfile
}
type ExternalLoginRequest ¶
type ExternalLoginRequest struct {
Identity ExternalIdentity
Realm Realm
}
type Identifier ¶
type Identifier struct {
ID string
SubjectID SubjectID
Scheme IdentifierScheme
DisplayValue string
NormalizedValue string
VerifiedAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
Identifier stores both a display value and its scheme-specific canonical value. VerifiedAt is the only source for verification claims.
func (Identifier) IsVerified ¶
func (i Identifier) IsVerified() bool
type IdentifierInput ¶
type IdentifierInput struct {
Scheme IdentifierScheme
Value string
}
type IdentifierResolver ¶
type IdentifierResolver interface {
NormalizeIdentifier(ctx context.Context, input IdentifierInput) (IdentifierInput, error)
}
type IdentifierResolverFunc ¶
type IdentifierResolverFunc func(context.Context, IdentifierInput) (IdentifierInput, error)
func (IdentifierResolverFunc) NormalizeIdentifier ¶
func (f IdentifierResolverFunc) NormalizeIdentifier(ctx context.Context, input IdentifierInput) (IdentifierInput, error)
type IdentifierScheme ¶
type IdentifierScheme string
const IdentifierSchemeEmail IdentifierScheme = "email"
func (IdentifierScheme) Validate ¶
func (s IdentifierScheme) Validate() error
type IdentityLink ¶
type IdentityLinkStore ¶
type IdentityLinkStore interface {
ResolveIdentityLink(ctx context.Context, issuer, externalSubject string) (Account, IdentityLink, error)
CreateSSOAccount(ctx context.Context, record SSOAccountRecord) (Account, IdentityLink, error)
LinkIdentity(ctx context.Context, link IdentityLink) (IdentityLink, error)
}
type KeyRing ¶
type KeyRing struct {
// contains filtered or unexported fields
}
KeyRing is an immutable versioned set of 256-bit symmetric keys.
func (KeyRing) ActiveKeyID ¶
type LocalAccountRecord ¶
type LoginRequest ¶
type LoginRequest struct {
Credential Credential
Realm Realm
}
type LoginResult ¶
type MembershipGate ¶
type MembershipGateFunc ¶
func (MembershipGateFunc) AllowMembership ¶
type Notification ¶
type NotificationDelivery ¶
type NotificationDelivery struct {
ID string
// EncryptedEvent is the exact sealed event claimed by the managed worker.
// Delivery transports may persist this envelope, but never Notification's
// plaintext codes/tokens. Use ID for downstream idempotency; delivery is at-least-once.
EncryptedEvent EncryptedEvent
Notification Notification
ValidUntil time.Time
}
NotificationDelivery may be sent more than once before it is accepted, expires, or exhausts the attempt limit. A sender must use ID as its idempotency key when the underlying transport supports deduplication.
type NotificationDeliveryPolicy ¶ added in v0.5.0
type NotificationDeliveryPolicy uint8
NotificationDeliveryPolicy selects whether recovery and email commands are available. The zero value retains mandatory encrypted delivery.
const ( NotificationDeliveryRequired NotificationDeliveryPolicy = iota NotificationDeliveryDisabled )
type NotificationRenderer ¶
type NotificationRenderer interface {
RenderNotification(ctx context.Context, notification Notification) ([]byte, error)
}
type NotificationRendererFunc ¶
type NotificationRendererFunc func(context.Context, Notification) ([]byte, error)
func (NotificationRendererFunc) RenderNotification ¶
func (f NotificationRendererFunc) RenderNotification(ctx context.Context, notification Notification) ([]byte, error)
type NotificationSender ¶
type NotificationSender interface {
SendNotification(ctx context.Context, delivery NotificationDelivery) error
}
NotificationSender is the only delivery integration required from a host using the PostgreSQL managed notification queue.
type NotificationSenderFunc ¶
type NotificationSenderFunc func(context.Context, NotificationDelivery) error
func (NotificationSenderFunc) SendNotification ¶
func (f NotificationSenderFunc) SendNotification(ctx context.Context, delivery NotificationDelivery) error
type NotificationTransaction
deprecated
type PasswordChangeStoreResult ¶
type PasswordChangeStoreResult struct {
Status PasswordChangeStoreStatus
Account Account
}
type PasswordChangeStoreStatus ¶
type PasswordChangeStoreStatus string
const ( PasswordChangeStoreSucceeded PasswordChangeStoreStatus = "succeeded" PasswordChangeStoreConflict PasswordChangeStoreStatus = "conflict" PasswordChangeStoreMissing PasswordChangeStoreStatus = "missing" )
type PasswordEmailChangeRequest ¶ added in v0.5.0
type PasswordEmailChangeRequest struct {
SubjectID SubjectID
CurrentPassword string
NewEmail string
}
PasswordEmailChangeRequest binds reauthentication to the actor selected by the trusted host. Never populate SubjectID from an unauthenticated request body.
type PasswordHasher ¶
type PasswordHasher interface {
HashPassword(password string) (string, error)
// VerifyPassword returns nil on a match and an error on a mismatch. Runtime
// preserves native mismatch errors as invalid credentials. Operational errors
// must wrap ErrPasswordVerificationUnavailable, ErrPasswordHashOverloaded,
// context.Canceled or context.DeadlineExceeded instead.
VerifyPassword(phc, password string) error
}
type PasswordPolicy ¶
type PasswordPolicy struct {
MinLength int
MaxLength int
Blocklist CommonPasswordChecker
DisableBlocklist bool
}
func DefaultPasswordPolicy ¶
func DefaultPasswordPolicy() PasswordPolicy
func (PasswordPolicy) Validate ¶
func (p PasswordPolicy) Validate(password string) error
type PasswordResetConsumeRequest ¶
type PasswordResetConsumeRequest struct {
Selector string
Digest SecretDigest
PasswordPHC string
Now time.Time
}
type PasswordResetConsumeResult ¶
type PasswordResetConsumeResult struct {
Status PasswordResetConsumeStatus
Account Account
}
type PasswordResetConsumeStatus ¶
type PasswordResetConsumeStatus string
const ( PasswordResetConsumed PasswordResetConsumeStatus = "consumed" PasswordResetInvalid PasswordResetConsumeStatus = "invalid" PasswordResetExpired PasswordResetConsumeStatus = "expired" PasswordResetUsed PasswordResetConsumeStatus = "used" )
type PasswordResetReceipt ¶ added in v0.5.0
PasswordResetReceipt contains only public correlation identifiers, never a reset credential.
type PasswordResetRecord ¶
type PasswordResetStore ¶
type PasswordResetStore interface {
CreatePasswordReset(ctx context.Context, record PasswordResetRecord) error
ConsumePasswordReset(ctx context.Context, request PasswordResetConsumeRequest) (PasswordResetConsumeResult, error)
}
type PendingEmailChange ¶
type RateLimitPolicy ¶
func (RateLimitPolicy) Validate ¶
func (p RateLimitPolicy) Validate() error
type RateLimitRequest ¶
type RateLimitResult ¶
type RateLimitStore ¶
type RateLimitStore interface {
TakeRateLimit(ctx context.Context, request RateLimitRequest) (RateLimitResult, error)
}
type RefreshRotationRequest ¶
type RefreshRotationResult ¶
type RefreshRotationResult struct {
Status RefreshRotationStatus
Account Account
Session Session
FamilyID string
}
type RefreshRotationStatus ¶
type RefreshRotationStatus string
const ( RefreshRotationSucceeded RefreshRotationStatus = "succeeded" RefreshRotationInvalid RefreshRotationStatus = "invalid" RefreshRotationExpired RefreshRotationStatus = "expired" RefreshRotationRevoked RefreshRotationStatus = "revoked" RefreshRotationReplayed RefreshRotationStatus = "replayed" )
type RegisterRequest ¶
type RegisterRequest struct {
Email string
Password string
Profile BasicProfile
}
type RegisterResult ¶
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func NewRuntime ¶
func (*Runtime) AcknowledgeEncryptedEvent ¶
func (*Runtime) AuthenticateSession ¶ added in v0.5.0
AuthenticateSession validates current session/security state and realm membership.
func (*Runtime) ChangePassword ¶
func (*Runtime) CleanupExpiredEncryptedEvents ¶
func (*Runtime) ConfirmEmailChange ¶
func (*Runtime) DecryptNotificationEvent ¶
func (r *Runtime) DecryptNotificationEvent(event EncryptedEvent) (Notification, error)
func (*Runtime) FindAccount ¶
func (*Runtime) GetAccount ¶
func (*Runtime) LinkExternalIdentity ¶
func (r *Runtime) LinkExternalIdentity(ctx context.Context, auth AuthContext, external ExternalIdentity) (IdentityLink, error)
func (*Runtime) Login ¶
func (r *Runtime) Login(ctx context.Context, request LoginRequest) (LoginResult, error)
func (*Runtime) LoginExternal ¶
func (r *Runtime) LoginExternal(ctx context.Context, request ExternalLoginRequest) (LoginResult, error)
LoginExternal resolves or provisions an SSO-only account and creates a realm-bound session. An unverified email can receive only the user realm's limited confirmation session.
func (*Runtime) PendingEmailChange ¶
func (*Runtime) ProvisionTrustedLocalAccount ¶
func (r *Runtime) ProvisionTrustedLocalAccount(ctx context.Context, request RegisterRequest) (Account, error)
ProvisionTrustedLocalAccount creates a verified local account for an operator-controlled bootstrap or seed path. Interactive registration must use Register so that the account starts in confirmation scope.
func (*Runtime) Register ¶
func (r *Runtime) Register(ctx context.Context, request RegisterRequest) (RegisterResult, error)
func (*Runtime) RequestEmailChange ¶
func (r *Runtime) RequestEmailChange(ctx context.Context, subjectID SubjectID, newEmail string) error
RequestEmailChange is a trusted host API. The host must authorize the actor and require fresh authentication before calling it. Local-password HTTP flows should use RequestEmailChangeWithPassword instead.
func (*Runtime) RequestEmailChangeWithPassword ¶ added in v0.5.0
func (r *Runtime) RequestEmailChangeWithPassword(ctx context.Context, request PasswordEmailChangeRequest) error
RequestEmailChangeWithPassword verifies this subject's current local password before issuing an email-change challenge. The caller still owns session and actor-to-target authorization. SSO-only accounts need an explicit host-owned recent-IdP-authentication flow through RequestEmailChange; there is no fallback.
func (*Runtime) RequestPasswordReset ¶
func (*Runtime) RequestPasswordResetWithReceipt ¶ added in v0.5.0
func (r *Runtime) RequestPasswordResetWithReceipt( ctx context.Context, email string, bind func(context.Context, PasswordResetReceipt) error, ) error
RequestPasswordResetWithReceipt calls bind inside the initiating auth transaction after reset, encrypted notification and audit writes. A bind error rolls back all participating writes. No callback runs when no reset is issued. Privileged hosts must not expose whether bind ran to unauthenticated clients.
func (*Runtime) ResetPassword ¶
func (*Runtime) ResolveExternalIdentity ¶
func (r *Runtime) ResolveExternalIdentity(ctx context.Context, external ExternalIdentity) (Account, error)
ResolveExternalIdentity accepts only identity claims verified by a trusted provider adapter. Never bind unverified client JSON directly to this method.
func (*Runtime) SendEmailChallenge ¶
func (*Runtime) SetSubjectStatus ¶
func (*Runtime) UpdateBasicProfile ¶
func (*Runtime) VerifyAccessToken
deprecated
func (*Runtime) VerifyCredential ¶
VerifyCredential verifies a local credential without creating a session. It is intended for recent-authentication checks and trusted bootstrap flows.
func (*Runtime) VerifyEmailChallenge ¶
type RuntimeStore ¶
type RuntimeStore interface {
AccountStore
SessionStore
PasswordResetStore
EmailChallengeStore
EmailChangeStore
IdentityLinkStore
RateLimitStore
}
type SSOAccountRecord ¶
type SSOAccountRecord struct {
Account Account
Link IdentityLink
}
type SecretDigest ¶
type SecurityEvent ¶
type SecurityEventType ¶
type SecurityEventType string
const ( SecurityEventLoginFailed SecurityEventType = "login.failed" SecurityEventRefreshReplay SecurityEventType = "refresh.replay" SecurityEventPasswordResetIssued SecurityEventType = "password_reset.issued" SecurityEventPasswordResetUsed SecurityEventType = "password_reset.used" SecurityEventPasswordChanged SecurityEventType = "password.changed" SecurityEventEmailChallengeIssued SecurityEventType = "email_challenge.issued" SecurityEventEmailVerified SecurityEventType = "email.verified" SecurityEventEmailChangeIssued SecurityEventType = "email_change.issued" SecurityEventEmailChanged SecurityEventType = "email.changed" SecurityEventSessionRevoked SecurityEventType = "session.revoked" SecurityEventSessionsRevoked SecurityEventType = "sessions.revoked" SecurityEventSubjectStatusChanged SecurityEventType = "subject.status_changed" SecurityEventIdentityLinked SecurityEventType = "identity.linked" )
type Session ¶
type SessionRecord ¶
type SessionScope ¶
type SessionScope string
const ( SessionScopeAuthenticated SessionScope = "authenticated" SessionScopeConfirmation SessionScope = "confirmation" )
type SessionSecurity ¶
type SessionSecurity struct {
Session Session
SubjectStatus SubjectStatus
CurrentVersion int64
}
type SessionStore ¶
type SessionStore interface {
// PeekRefresh authenticates a token without consuming it. Rotation revalidates all state.
PeekRefresh(ctx context.Context, request RefreshRotationRequest) (RefreshRotationResult, error)
CreateSession(ctx context.Context, record SessionRecord) error
RotateRefresh(ctx context.Context, request RefreshRotationRequest) (RefreshRotationResult, error)
IntrospectSession(ctx context.Context, sessionID string) (SessionSecurity, error)
RevokeSession(ctx context.Context, subjectID SubjectID, sessionID string, now time.Time) (bool, error)
RevokeSubjectSessions(ctx context.Context, subjectID SubjectID, now time.Time) (int64, error)
SetSubjectStatus(ctx context.Context, subjectID SubjectID, status SubjectStatus, now time.Time) (Subject, error)
}
type SigningConfig ¶
type Subject ¶
type Subject struct {
ID SubjectID
Status SubjectStatus
SecurityVersion int64
CreatedAt time.Time
UpdatedAt time.Time
}
Subject is the canonical security principal. Profile, identifiers, credentials, memberships, and permissions deliberately live elsewhere.
type SubjectID ¶
SubjectID is the canonical identifier shared by every goauth relation.
func MustParseSubjectID ¶
func NewSubjectID ¶
func NewSubjectID() SubjectID
func ParseSubjectID ¶
func (SubjectID) MarshalText ¶
func (*SubjectID) UnmarshalText ¶
type SubjectStatus ¶
type SubjectStatus string
const ( SubjectStatusActive SubjectStatus = "active" SubjectStatusSuspended SubjectStatus = "suspended" SubjectStatusDisabled SubjectStatus = "disabled" )
func (SubjectStatus) Validate ¶
func (s SubjectStatus) Validate() error
type URLBuilder ¶
type URLBuilderFunc ¶
func (URLBuilderFunc) PasswordResetURL ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
externalconsumerprobe
command
|
|
|
releaseevidence
command
Command releaseevidence validates a complete public-preview evidence manifest.
|
Command releaseevidence validates a complete public-preview evidence manifest. |
|
examples
|
|
|
nethttp
command
Command nethttp demonstrates host-owned browser transport and bearer-only API routes backed by a single PostgreSQL Runtime.
|
Command nethttp demonstrates host-owned browser transport and bearer-only API routes backed by a single PostgreSQL Runtime. |
|
internal
|
|
|
authclock
Package authclock carries the Runtime clock across its transaction boundary.
|
Package authclock carries the Runtime clock across its transaction boundary. |
|
retryafter
Package retryafter extracts a transport-independent retry deadline.
|
Package retryafter extracts a transport-independent retry deadline. |
|
Package nethttp adapts goauth to standard-library JSON HTTP handlers.
|
Package nethttp adapts goauth to standard-library JSON HTTP handlers. |
|
reference
|
|
|
externalconsumer
Package externalconsumer is a compile-checked manifest of the goauth packages that are currently supported for external consumers such as backend and goadmin.
|
Package externalconsumer is a compile-checked manifest of the goauth packages that are currently supported for external consumers such as backend and goadmin. |