Documentation
¶
Overview ¶
Package domain holds the IAM domain model: aggregate roots and the command value-objects services pass to the aggregate ports.
Architecture (decided 2026-06-05):
- An aggregate root is the transactional consistency boundary. Each port method is ONE atomic business operation; the persistence adapter opens the transaction INSIDE the method — services never touch pgtx.
- API services (pkg/api) are pure orchestration: map oas -> domain, call one or more aggregate-port methods, map domain -> oas. They hold only interfaces (consumer-defined, next to each service).
- Cross-aggregate consistency is out of scope here (events/outbox come later); a single call mutates a single aggregate.
Fields are representative; they grow as operations are implemented.
Index ¶
- Variables
- func ValidateEmail(email string) error
- func ValidatePhone(phone string) error
- type APIKey
- type APIKeyCmd
- type Account
- type AccountAcceptConsentsCmd
- type AccountActivityCmd
- type AccountActivityEvent
- type AccountActivityPage
- type AccountConsent
- type AccountConsentAcceptance
- type AccountExportJob
- type AccountMergeConfirmCmd
- type AccountMergeStartCmd
- type AccountRenameSessionCmd
- type AccountRevokeSessionsCmd
- type AccountTrustSessionCmd
- type AdminAPIKeyCmd
- type AdminAPIKeySecret
- type AdminAPIKeyUpdateCmd
- type AdminAccessRequestDecisionCmd
- type AdminAccessRequestListCmd
- type AdminAccessRequestPage
- type AdminConfigDoc
- type AdminConfigGetCmd
- type AdminConfigUpdateCmd
- type AdminConnectionCmd
- type AdminDomainCmd
- type AdminDomainRegistration
- type AdminFeaturesUpdateCmd
- type AdminI18nUpdateCmd
- type AdminImpersonation
- type AdminJWKSRotateCmd
- type AdminProvider
- type AdminProviderCmd
- type AdminProviderDeleteCmd
- type AdminSecret
- type AdminServiceAccountSecretCmd
- type AdminServiceAccountUpdateCmd
- type AdminSigningKey
- type AdminTemplatePreview
- type AdminTemplatePreviewCmd
- type AdminTemplateSendTestCmd
- type AdminTemplateUpdateCmd
- type AdminTokenProfile
- type AdminTokenProfileCmd
- type AdminTokenProfilePreviewCmd
- type AdminUserAnonymizeCmd
- type AdminUserBanCmd
- type AdminUserImpersonateCmd
- type AdminUserPasswordCmd
- type AdminUserSessionsRevokeCmd
- type AdminUserUpdateCmd
- type AppClient
- type AppClientCmd
- type Challenge
- type Connection
- type ConnectionCmd
- type ConsentDocument
- type CoreAuthAccessRequest
- type CoreAuthAccessRequestCmd
- type CoreAuthCaptchaVerifyResult
- type CoreAuthEmailVerificationCallbackCmd
- type CoreAuthEmailVerificationCallbackResult
- type CoreAuthPasswordChangeCmd
- type CoreAuthPasswordCheckResult
- type CoreAuthPasswordForgotCmd
- type CoreAuthPasswordResetCmd
- type CoreAuthPasswordVerifyResult
- type CoreAuthRevokeCmd
- type CoreAuthStepUpCmd
- type CoreAuthStepUpResult
- type CoreAuthTokenIntrospection
- type CoreAuthTokenVerification
- type CoreAuthVerifyConsumeCmd
- type CoreAuthVerifyStartCmd
- type Domain
- type Environment
- type EnvironmentCmd
- type Error
- type Event
- type Factor
- type FederationConnectionConfig
- type FederationConnectionUpdateCmd
- type FederationOidcConfig
- type FederationSamlAcsCmd
- type FederationSamlConfig
- type FederationScimListQuery
- type FederationScimPatchCmd
- type FederationScimResource
- type FederationScimTokenCmd
- type FederationScimWriteCmd
- type FederationSsoCallbackCmd
- type FederationSsoRedirect
- type FederationSsoStartCmd
- type Grant
- type Identity
- type Interaction
- type MFAEmailEnrollCmd
- type MFARecoveryVerifyCmd
- type MFASmsEnrollCmd
- type MFATotpVerifyCmd
- type MFAWebAuthnEnrollOptionsCmd
- type MFAWebAuthnEnrollVerifyCmd
- type MachineIDAPIKeyPatchCmd
- type MachineIDSecret
- type MachineIDSecretCmd
- type MachineIDServiceAccountListCmd
- type MachineIDServiceAccountPage
- type MachineIDServiceAccountPatchCmd
- type OAuthProvider
- type OAuthSocialCallbackCmd
- type OAuthSocialCallbackResult
- type OAuthSocialExchangeCmd
- type OAuthSocialLinkCallbackCmd
- type OAuthSocialLinkStartCmd
- type OAuthSocialStartCmd
- type OIDCAuthorizeCmd
- type OIDCBackchannelLogoutCmd
- type OIDCConsentCmd
- type OIDCDeviceAuthorization
- type OIDCDeviceAuthorizationCmd
- type OIDCDeviceDecisionCmd
- type OIDCDevicePending
- type OIDCDeviceUserCode
- type OIDCIntrospectCmd
- type OIDCLogoutCmd
- type OIDCParCmd
- type OIDCParResult
- type OIDCRejectCmd
- type OIDCRevokeCmd
- type OIDCTokenCmd
- type OperatorAdminToken
- type OperatorAdminTokenCmd
- type OperatorConfigCmd
- type OperatorFeaturesCmd
- type OperatorProjectPatchCmd
- type PlatformCsrfToken
- type Principal
- type PrincipalKind
- type ProfileUpdateCmd
- type Project
- type ProjectCmd
- type PublicConfig
- type RegisterCmd
- type ScimToken
- type ServiceAccount
- type ServiceAccountCmd
- type Session
- type WebAuthnCeremonyData
- type WebAuthnCredential
- type WebAuthnRenameCredentialCmd
- type WebAuthnStoredCredential
Constants ¶
This section is empty.
Variables ¶
var ( // 401 — authentication. ErrInvalidCredentials = newErr(http.StatusUnauthorized, "invalid_credentials", "Invalid credentials.") ErrInvalidToken = newErr(http.StatusUnauthorized, "invalid_token", "The token is invalid.") ErrTokenExpired = newErr(http.StatusUnauthorized, "token_expired", "The token has expired.") ErrTokenRevoked = newErr(http.StatusUnauthorized, "token_revoked", "The token has been revoked.") ErrMFAInvalid = newErr(http.StatusUnauthorized, "mfa_invalid", "Invalid MFA code.") ErrInvalidOTP = newErr(http.StatusUnauthorized, "invalid_otp", "Invalid one-time code.") ErrChallengeInvalid = newErr(http.StatusUnauthorized, "challenge_invalid", "Invalid challenge.") // 403 — permitted-but-blocked / gated. ErrForbidden = newErr(http.StatusForbidden, "forbidden", "Not permitted.") ErrAccountSuspended = newErr(http.StatusForbidden, "account_suspended", "Account suspended.") ErrAccountBanned = newErr(http.StatusForbidden, "account_banned", "Account banned.") ErrAccountLocked = newErr(http.StatusForbidden, "account_locked", "Account locked.") ErrEmailNotVerified = newErr(http.StatusForbidden, "email_not_verified", "Email not verified.") ErrPhoneNotVerified = newErr(http.StatusForbidden, "phone_not_verified", "Phone not verified.") ErrMFARequired = newErr(http.StatusForbidden, "mfa_required", "MFA is required.") ErrStepUpRequired = newErr(http.StatusForbidden, "step_up_required", "Step-up authentication is required.") ErrRegistrationClosed = newErr(http.StatusForbidden, "registration_closed", "Registration is closed.") ErrInvitationRequired = newErr(http.StatusForbidden, "invitation_required", "An invitation is required.") ErrCaptchaRequired = newErr(http.StatusForbidden, "captcha_required", "Captcha is required.") ErrCaptchaInvalid = newErr(http.StatusForbidden, "captcha_invalid", "Invalid captcha.") ErrConsentRequired = newErr(http.StatusForbidden, "consent_required", "Consent is required.") ErrInvalidCsrf = newErr(http.StatusForbidden, "invalid_csrf", "Missing or invalid CSRF token.") // 404 — not found / not visible. ErrNotFound = newErr(http.StatusNotFound, "not_found", "Not found.") ErrUserNotFound = newErr(http.StatusNotFound, "user_not_found", "User not found.") ErrSessionNotFound = newErr(http.StatusNotFound, "session_not_found", "Session not found.") ErrProjectNotFound = newErr(http.StatusNotFound, "project_not_found", "Project not found.") ErrEnvironmentNotFound = newErr(http.StatusNotFound, "environment_not_found", "Environment not found.") ErrClientNotFound = newErr(http.StatusNotFound, "client_not_found", "App client not found.") ErrConnectionNotFound = newErr(http.StatusNotFound, "connection_not_found", "Connection not found.") ErrDomainNotFound = newErr(http.StatusNotFound, "domain_not_found", "Domain not found.") // 409 — conflict. ErrConflict = newErr(http.StatusConflict, "conflict", "Conflicting state.") ErrEmailExists = newErr(http.StatusConflict, "email_exists", "Email already in use.") ErrPhoneExists = newErr(http.StatusConflict, "phone_exists", "Phone already in use.") ErrIdentityExists = newErr(http.StatusConflict, "identity_exists", "Identity already linked.") ErrAlreadyLinked = newErr(http.StatusConflict, "already_linked", "Already linked.") ErrDomainTaken = newErr(http.StatusConflict, "domain_taken", "Domain already claimed.") // 410 — gone / single-use consumed. ErrChallengeExpired = newErr(http.StatusGone, "challenge_expired", "The challenge has expired.") ErrTokenUsed = newErr(http.StatusGone, "token_already_used", "The token has already been used.") // 422 — validation. ErrValidation = newErr(http.StatusUnprocessableEntity, "validation_failed", "Validation failed.") ErrWeakPassword = newErr(http.StatusUnprocessableEntity, "weak_password", "The password is too weak.") ErrPasswordReused = newErr(http.StatusUnprocessableEntity, "password_reused", "The password was used before.") // 400 — malformed. ErrBadRequest = newErr(http.StatusBadRequest, "bad_request", "Invalid request.") ErrUnsupportedGrant = newErr(http.StatusBadRequest, "unsupported_grant", "Unsupported grant type.") // 429 — throttled. ErrRateLimited = newErr(http.StatusTooManyRequests, "rate_limited", "Too many requests.") // 502/503/500 — downstream / server. ErrProviderError = newErr(http.StatusBadGateway, "provider_error", "Upstream provider error.") ErrSSOError = newErr(http.StatusBadGateway, "sso_error", "SSO error.") ErrSCIMError = newErr(http.StatusBadGateway, "scim_error", "SCIM error.") ErrInternal = newErr(http.StatusInternalServerError, "internal_error", "Internal error.") )
The complete catalogue of domain errors. Branch with errors.Is.
Functions ¶
func ValidateEmail ¶
ValidateEmail checks basic email format (contains @, has a domain part with a dot). This is NOT a full RFC 5322 check — it rejects obviously malformed addresses without false-positive-rejecting valid ones.
func ValidatePhone ¶
ValidatePhone checks that phone matches E.164 format (starts with +, 7-15 digits after the plus sign, no leading zero on the country code).
Types ¶
type AccountAcceptConsentsCmd ¶
type AccountAcceptConsentsCmd struct {
AccountID string
Accept []AccountConsentAcceptance
}
AccountAcceptConsentsCmd accepts one or more consent documents.
type AccountActivityCmd ¶
AccountActivityCmd queries the account activity log.
type AccountActivityEvent ¶
AccountActivityEvent is a single audit/activity record on the account.
type AccountActivityPage ¶
type AccountActivityPage struct {
Events []AccountActivityEvent
NextCursor string
HasMore bool
}
AccountActivityPage is a cursor-paginated slice of activity events.
type AccountConsent ¶
type AccountConsent struct {
Key string
Version string
URL string
AcceptedAt time.Time
Locale string
}
AccountConsent is a recorded consent acceptance on the account.
type AccountConsentAcceptance ¶
AccountConsentAcceptance records acceptance of one consent document.
type AccountExportJob ¶
AccountExportJob describes a pending or finished data-export job.
type AccountMergeConfirmCmd ¶
AccountMergeConfirmCmd confirms a pending identity merge with a challenge code.
type AccountMergeStartCmd ¶
AccountMergeStartCmd begins linking/merging another identity into the account.
type AccountRenameSessionCmd ¶
AccountRenameSessionCmd sets a human-friendly device name on a session.
type AccountRevokeSessionsCmd ¶
type AccountRevokeSessionsCmd struct {
AccountID string
ExceptSessionID string // if set, this session is kept
ExceptCurrent bool
}
AccountRevokeSessionsCmd bulk-revokes sessions for the account.
type AccountTrustSessionCmd ¶
AccountTrustSessionCmd marks a session as trusted for a duration.
type AdminAPIKeyCmd ¶
AdminAPIKeyCmd creates a project API key.
type AdminAPIKeySecret ¶
AdminAPIKeySecret is an API key plus its one-time plaintext secret.
type AdminAPIKeyUpdateCmd ¶
type AdminAPIKeyUpdateCmd struct {
ProjectID string
KeyID string
Name string
Scopes []string
Disabled bool
}
AdminAPIKeyUpdateCmd updates an API key's name / scopes / state.
type AdminAccessRequestDecisionCmd ¶
type AdminAccessRequestDecisionCmd struct {
ProjectID string
Environment string
RequestID string
ActorID string
Reason string
}
AdminAccessRequestDecisionCmd approves or denies an access request.
type AdminAccessRequestListCmd ¶
type AdminAccessRequestListCmd struct {
ProjectID string
Environment string
Status string
Cursor string
}
AdminAccessRequestListCmd lists pending access requests.
type AdminAccessRequestPage ¶
type AdminAccessRequestPage struct {
Items []CoreAuthAccessRequest
NextCursor string
HasMore bool
}
AdminAccessRequestPage is a page of access requests.
type AdminConfigDoc ¶
AdminConfigDoc is an opaque, fully-typed configuration document carried between the API layer and the adapter as a map of raw JSON fields. Services never interpret it: the adapter validates/persists, the API layer round-trips it to/from the matching generated oas type. Used for auth / password-policy / session-policy / consent configuration objects.
type AdminConfigGetCmd ¶
AdminConfigGetCmd selects a configuration document for read.
type AdminConfigUpdateCmd ¶
type AdminConfigUpdateCmd struct {
ProjectID string
Environment string
Doc AdminConfigDoc
}
AdminConfigUpdateCmd carries a (partial or full) configuration document to apply. Doc is the wire object the admin sent, opaque to the service.
type AdminConnectionCmd ¶
type AdminConnectionCmd struct {
ProjectID string
Type string
Name string
Domains []string
ExternalRef string
}
AdminConnectionCmd creates an SSO connection.
type AdminDomainCmd ¶
AdminDomainCmd registers a verification domain.
type AdminDomainRegistration ¶
type AdminDomainRegistration struct {
Domain *Domain
VerificationRecordType string
VerificationRecordName string
VerificationRecordValue string
}
AdminDomainRegistration is a domain plus the DNS record proving ownership.
type AdminFeaturesUpdateCmd ¶
AdminFeaturesUpdateCmd toggles project feature flags.
type AdminI18nUpdateCmd ¶
type AdminI18nUpdateCmd struct {
ProjectID string
Environment string
Locale string
Messages map[string]jx.Raw
}
AdminI18nUpdateCmd replaces the i18n bundle for a locale.
type AdminImpersonation ¶
AdminImpersonation is the result of an impersonation request.
type AdminJWKSRotateCmd ¶
AdminJWKSRotateCmd rotates the signing key set, optionally activating the new key immediately.
type AdminProvider ¶
AdminProvider is a configured notification provider (email or SMS). Config is an opaque settings bag the adapter interprets.
type AdminProviderCmd ¶
type AdminProviderCmd struct {
ProjectID string
Environment string
ID string // empty on create
Type string
Config map[string]jx.Raw
Enabled bool
}
AdminProviderCmd creates or replaces a notification provider.
type AdminProviderDeleteCmd ¶
AdminProviderDeleteCmd removes a notification provider.
type AdminSecret ¶
AdminSecret is a freshly minted machine credential. The plaintext secret is returned exactly once.
type AdminServiceAccountSecretCmd ¶
type AdminServiceAccountSecretCmd struct {
ProjectID string
ServiceAccountID string
Name string
ExpiresAt time.Time
}
AdminServiceAccountSecretCmd issues a new secret for a service account.
type AdminServiceAccountUpdateCmd ¶
type AdminServiceAccountUpdateCmd struct {
ProjectID string
ServiceAccountID string
Scopes []string
Disabled bool
}
AdminServiceAccountUpdateCmd updates a service account's scopes / state.
type AdminSigningKey ¶
AdminSigningKey is a JWKS signing key in its administrative form.
type AdminTemplatePreview ¶
AdminTemplatePreview is a rendered email template.
type AdminTemplatePreviewCmd ¶
type AdminTemplatePreviewCmd struct {
ProjectID string
Environment string
TemplateID string
Locale string
Data map[string]jx.Raw
}
AdminTemplatePreviewCmd renders an email template with sample data.
type AdminTemplateSendTestCmd ¶
type AdminTemplateSendTestCmd struct {
ProjectID string
Environment string
TemplateID string
To string
Locale string
Data map[string]jx.Raw
}
AdminTemplateSendTestCmd sends a rendered template to a test address.
type AdminTemplateUpdateCmd ¶
type AdminTemplateUpdateCmd struct {
ProjectID string
Environment string
TemplateID string
Patch map[string]jx.Raw
}
AdminTemplateUpdateCmd patches an email template.
type AdminTokenProfile ¶
type AdminTokenProfile struct {
ID string
Name string
Audience string
AccessTTL int
RefreshTTL int
ClaimsTemplate map[string]jx.Raw
}
AdminTokenProfile is a token-shaping profile.
type AdminTokenProfileCmd ¶
type AdminTokenProfileCmd struct {
ProjectID string
Environment string
ID string // empty on create
Profile AdminConfigDoc
}
AdminTokenProfileCmd creates or replaces a token profile.
type AdminTokenProfilePreviewCmd ¶
type AdminTokenProfilePreviewCmd struct {
ProjectID string
Environment string
ProfileID string
UserID string
}
AdminTokenProfilePreviewCmd renders the claims a profile would produce for a user.
type AdminUserAnonymizeCmd ¶
AdminUserAnonymizeCmd anonymizes (GDPR erase) a user.
type AdminUserBanCmd ¶
AdminUserBanCmd bans a user, optionally with a reason and an expiry.
type AdminUserImpersonateCmd ¶
type AdminUserImpersonateCmd struct {
ProjectID string
AccountID string
ActorID string // the admin performing the impersonation
Reason string
DurationSeconds int
}
AdminUserImpersonateCmd mints a time-boxed impersonation link.
type AdminUserPasswordCmd ¶
type AdminUserPasswordCmd struct {
ProjectID string
AccountID string
Password string
RevokeSessions bool
}
AdminUserPasswordCmd sets a user's password out-of-band.
type AdminUserSessionsRevokeCmd ¶
type AdminUserSessionsRevokeCmd struct {
ProjectID string
AccountID string
ExceptSessionID string
Reason string
}
AdminUserSessionsRevokeCmd revokes a user's sessions, optionally keeping one.
type AdminUserUpdateCmd ¶
AdminUserUpdateCmd is a partial profile update applied by a project admin.
type AppClientCmd ¶
type Connection ¶
type Connection struct {
ID string
ProjectID string
Type string // saml | oidc
Name string
Status string
Domains []string
ExternalRef string
// Config carries the protocol-specific provider settings (SAML IdP metadata
// / certificate, OIDC issuer / client credentials). It is persisted whole in
// the connection's jsonb envelope; see FederationSamlConfig / FederationOidcConfig.
Config *FederationConnectionConfig `json:",omitempty"`
}
type ConnectionCmd ¶
func (ConnectionCmd) Validate ¶
func (c ConnectionCmd) Validate() error
Validate checks connection-create invariants.
type ConsentDocument ¶
type CoreAuthAccessRequest ¶
type CoreAuthAccessRequest struct {
ID string
ProjectID string
Email string
Reason string
Status string
}
CoreAuthAccessRequest is a request for access to a project that gates self-service sign-up behind approval.
type CoreAuthAccessRequestCmd ¶
type CoreAuthAccessRequestCmd struct {
ProjectID string
Email string
Reason string
CaptchaToken string
}
CoreAuthAccessRequestCmd creates an access request.
type CoreAuthCaptchaVerifyResult ¶
CoreAuthCaptchaVerifyResult is the outcome of verifying a CAPTCHA token with the configured provider.
type CoreAuthEmailVerificationCallbackCmd ¶
CoreAuthEmailVerificationCallbackCmd consumes an opaque email-verification link token and resolves where to send the browser next.
type CoreAuthEmailVerificationCallbackResult ¶
CoreAuthEmailVerificationCallbackResult is the outcome of consuming an email verification link: the absolute redirect URL and an optional Set-Cookie value (e.g. a freshly issued session cookie) for the browser.
type CoreAuthPasswordChangeCmd ¶
type CoreAuthPasswordChangeCmd struct {
AccountID string
SessionID string
CurrentPassword string
NewPassword string
RevokeOtherSessions bool
}
CoreAuthPasswordChangeCmd changes the current account's password.
type CoreAuthPasswordCheckResult ¶
CoreAuthPasswordCheckResult is the outcome of a policy/strength check.
type CoreAuthPasswordForgotCmd ¶
type CoreAuthPasswordForgotCmd struct {
ProjectID string
Email string
RedirectTo string
Locale string
CaptchaToken string
}
CoreAuthPasswordForgotCmd begins a password-reset flow for an email.
type CoreAuthPasswordResetCmd ¶
type CoreAuthPasswordResetCmd struct {
ProjectID string
Token string
ChallengeID string
Code string
NewPassword string
}
CoreAuthPasswordResetCmd completes a password-reset flow with a fresh password. Exactly one of Token or (ChallengeID+Code) identifies the request.
type CoreAuthPasswordVerifyResult ¶
CoreAuthPasswordVerifyResult is the outcome of re-asserting the current account's password (e.g. for a sudo/step-up gate).
type CoreAuthRevokeCmd ¶
CoreAuthRevokeCmd revokes a token or a whole session.
type CoreAuthStepUpCmd ¶
type CoreAuthStepUpCmd struct {
AccountID string
SessionID string
Purpose string
RequiredAAL int
MaxAgeSeconds int
HasMaxAge bool
}
CoreAuthStepUpCmd requests elevation of the current session to a higher AAL.
type CoreAuthStepUpResult ¶
CoreAuthStepUpResult is the outcome of a step-up request. When Satisfied is true the session already meets the bar; otherwise a Challenge gates it.
type CoreAuthTokenIntrospection ¶
CoreAuthTokenIntrospection is the result of introspecting a token.
type CoreAuthTokenVerification ¶
CoreAuthTokenVerification is the result of verifying a token.
type CoreAuthVerifyConsumeCmd ¶
type CoreAuthVerifyConsumeCmd struct {
ProjectID string
AccountID string // empty for unauthenticated consume
ChallengeID string
Code string
Token string
}
CoreAuthVerifyConsumeCmd consumes a verification/change challenge. Exactly one of (ChallengeID+Code) or Token identifies the challenge.
type CoreAuthVerifyStartCmd ¶
type CoreAuthVerifyStartCmd struct {
ProjectID string
AccountID string // empty for unauthenticated start (public verification)
Contact string // the email or phone to verify; empty -> use the account's primary
RedirectTo string
Locale string
Channel string // sms | whatsapp (phone only)
}
CoreAuthVerifyStartCmd starts an email or phone verification/change flow. One challenge is minted and (for email/phone) a code or link is dispatched.
type Environment ¶
type EnvironmentCmd ¶
type Error ¶
Error is a domain error carrying the stable machine code, an HTTP status and a default human message. The persistence/service layers return these; the API layer (pkg/api NewError) renders them into the ErrorEnvelope. Equality is by Code, so errors.Is(err, ErrInvalidCredentials) matches any *Error with the same code, whether a sentinel or a freshly built one with details.
func (*Error) Is ¶
Is matches by Code so wrapped/rebuilt errors still compare equal to the sentinel of the same code.
func (*Error) WithDetails ¶
WithDetails returns a copy carrying structured context.
func (*Error) WithMessage ¶
WithMessage returns a copy with an overridden human message.
type Event ¶
type Event struct {
// ID is the unique event id (uuid). Consumers deduplicate on it because
// outbox delivery is at-least-once.
ID string
// Type is the event name, "<aggregate>.<verb>" (e.g. "api_key.created").
Type string
// ProjectID is the owning tenant; used as the outbox partition key so events
// for one project stay ordered.
ProjectID string
// Environment is the project environment (live/…); empty when not applicable.
Environment string
// AggregateID is the id of the affected aggregate instance.
AggregateID string
// OccurredAt is when the event happened (UTC).
OccurredAt time.Time
// Payload is the aggregate snapshot (or, for delivery events, the dispatch
// envelope). JSON-serialised into the outbox message body.
Payload any
}
Event is a domain event emitted transactionally through the outbox: the adapter that mutates an aggregate enqueues the event inside the same database transaction, so the event is durably recorded iff the mutation commits.
Payload carries a full snapshot of the affected aggregate (the subscriber is an in-infrastructure consumer that wants the state in-context, not a public API). Delivery events (auth.otp.started, auth.magiclink.started, …) carry the plaintext secret needed to dispatch the message — that plaintext lands in the outbox at rest and is the reason outbox payloads are an encryption target.
type Factor ¶
type Factor struct {
ID string
Type string // totp | sms | email | webauthn
Status string // pending | active
Hint string
// OTPAuthURL is the otpauth:// provisioning URL returned to the caller at
// TOTP enrollment time so it can be rendered as a QR code. It is transient
// provisioning material, not a stored credential (the shared secret lives
// in iam_factors.secret), so it is excluded from the persisted aggregate.
OTPAuthURL string `json:"-"`
}
type FederationConnectionConfig ¶
type FederationConnectionConfig struct {
Saml *FederationSamlConfig `json:"saml,omitempty"`
Oidc *FederationOidcConfig `json:"oidc,omitempty"`
}
FederationConnectionConfig is the protocol-specific provider configuration of an SSO connection, persisted whole in the connection's jsonb envelope. Exactly one of Saml / Oidc is populated, matching Connection.Type.
type FederationConnectionUpdateCmd ¶
FederationConnectionUpdateCmd is a partial update of an SSO connection. The Patch map carries only the fields the caller supplied (decoded from the free-form JSON merge-patch body); the adapter applies them atomically.
type FederationOidcConfig ¶
type FederationOidcConfig struct {
Issuer string `json:"issuer,omitempty"`
AuthURL string `json:"auth_url,omitempty"`
TokenURL string `json:"token_url,omitempty"`
JWKSURL string `json:"jwks_url,omitempty"`
ClientID string `json:"client_id,omitempty"`
ClientSecret string `json:"client_secret,omitempty"`
RedirectURL string `json:"redirect_url,omitempty"`
Scopes []string `json:"scopes,omitempty"`
}
FederationOidcConfig carries the external OIDC provider settings used to drive the authorization-code leg and to verify the returned id_token.
type FederationSamlAcsCmd ¶
FederationSamlAcsCmd completes an inbound SAML assertion consumer leg. The adapter validates the assertion, links the account and returns the post-login redirect URL plus an optional session cookie.
type FederationSamlConfig ¶
type FederationSamlConfig struct {
// IDPMetadataXML is the IdP's SAML metadata document (entityID, SSO URL,
// signing certificate). When present it is the authoritative source.
IDPMetadataXML string `json:"idp_metadata_xml,omitempty"`
// IDPCertificatePEM is a fallback IdP signing certificate (PEM) used when no
// full metadata document is available.
IDPCertificatePEM string `json:"idp_certificate_pem,omitempty"`
// EntityID is the SP entity ID advertised to the IdP. Defaults to MetadataURL.
EntityID string `json:"entity_id,omitempty"`
// AcsURL is the SP Assertion Consumer Service URL (where the IdP POSTs the
// signed Response).
AcsURL string `json:"acs_url,omitempty"`
// MetadataURL is the SP metadata endpoint URL.
MetadataURL string `json:"metadata_url,omitempty"`
// SPCertificatePEM / SPPrivateKeyPEM is the SP's own signing keypair used to
// sign AuthnRequests and to advertise the SP signing certificate in metadata.
// Optional: when absent the SP runs without request signing.
SPCertificatePEM string `json:"sp_certificate_pem,omitempty"`
SPPrivateKeyPEM string `json:"sp_private_key_pem,omitempty"`
}
FederationSamlConfig carries the SAML Service Provider's view of an IdP: the IdP metadata XML (preferred) or a raw IdP signing certificate, plus the SP endpoint URLs used to build the AuthnRequest / ACS / metadata documents.
type FederationScimListQuery ¶
FederationScimListQuery is a paginated SCIM list request.
type FederationScimPatchCmd ¶
FederationScimPatchCmd applies a SCIM PATCH operation set to a resource.
type FederationScimResource ¶
FederationScimResource is an opaque SCIM resource (User or Group) carried as a free-form attribute map. pkg/api maps it to/from the generated wire maps; the adapter owns the SCIM schema semantics.
type FederationScimTokenCmd ¶
type FederationScimTokenCmd struct {
ProjectID string
ConnectionID string
Name string
ExpiresAt time.Time
}
FederationScimTokenCmd mints a new SCIM provisioning bearer token scoped to a single SSO connection.
type FederationScimWriteCmd ¶
type FederationScimWriteCmd struct {
ConnectionID string
ResourceID string // empty on create
Attributes map[string]any
}
FederationScimWriteCmd creates or replaces a SCIM resource on a connection.
type FederationSsoCallbackCmd ¶
FederationSsoCallbackCmd completes an inbound OIDC callback. The adapter exchanges the code, provisions/links the account and returns the post-login redirect URL plus an optional session cookie.
type FederationSsoRedirect ¶
type FederationSsoRedirect struct {
URL string
// Cookie carries the session cookies (access + refresh) to set in cookie
// mode; each entry is a full Set-Cookie header value.
Cookie []string
}
FederationSsoRedirect is a runtime SSO redirect result: the URL the caller's browser must be sent to, plus an optional Set-Cookie value.
type FederationSsoStartCmd ¶
type FederationSsoStartCmd struct {
ConnectionID string
RedirectTo string
State string
LoginHint string
}
FederationSsoStartCmd begins an outbound SSO authentication leg (OIDC authorization-code or SAML AuthnRequest). The adapter builds the provider redirect URL (with PKCE / RelayState baked in) and returns it; pkg/api just orchestrates the 302.
type Interaction ¶
type MFAEmailEnrollCmd ¶
MFAEmailEnrollCmd enrolls an email factor and issues a delivery challenge.
type MFARecoveryVerifyCmd ¶
MFARecoveryVerifyCmd consumes a recovery code to complete an MFA flow.
type MFASmsEnrollCmd ¶
MFASmsEnrollCmd enrolls an SMS factor and issues a delivery challenge.
type MFATotpVerifyCmd ¶
MFATotpVerifyCmd activates a pending TOTP factor by verifying a code.
type MFAWebAuthnEnrollOptionsCmd ¶
MFAWebAuthnEnrollOptionsCmd requests creation options for a new WebAuthn factor enrollment.
type MFAWebAuthnEnrollVerifyCmd ¶
type MFAWebAuthnEnrollVerifyCmd struct {
AccountID string
ChallengeID string
Credential map[string]any
}
MFAWebAuthnEnrollVerifyCmd verifies the attestation produced by the authenticator and activates the WebAuthn factor.
type MachineIDAPIKeyPatchCmd ¶
type MachineIDAPIKeyPatchCmd struct {
ProjectID string
KeyID string
Name string
Scopes []string
Disabled *bool
}
MachineIDAPIKeyPatchCmd updates API-key metadata/scopes.
type MachineIDSecret ¶
MachineIDSecret is the result of creating a service-account client secret. ClientSecret is the plaintext value, returned exactly once at creation.
type MachineIDSecretCmd ¶
type MachineIDSecretCmd struct {
ProjectID string
ServiceAccountID string
Name string
ExpiresAt *time.Time
}
MachineIDSecretCmd mints a new client secret for a service account.
type MachineIDServiceAccountListCmd ¶
MachineIDServiceAccountListCmd queries service accounts in a project.
type MachineIDServiceAccountPage ¶
type MachineIDServiceAccountPage struct {
Items []*ServiceAccount
NextCursor string
HasMore bool
}
MachineIDServiceAccountPage is a cursor-paginated slice of service accounts.
type MachineIDServiceAccountPatchCmd ¶
type MachineIDServiceAccountPatchCmd struct {
ProjectID string
ServiceAccountID string
Scopes []string
Disabled *bool
}
MachineIDServiceAccountPatchCmd updates a service account's scopes/disabled state.
type OAuthProvider ¶
type OAuthSocialCallbackCmd ¶
type OAuthSocialCallbackCmd struct {
ProjectID string
Provider string
Code string
State string
Error string
CodeVerifier string // optional PKCE verifier paired with the StartLogin challenge
RedirectTo string // product URL to bounce the browser back to after minting
}
OAuthSocialCallbackCmd carries the provider callback query parameters back to the adapter, which validates state, exchanges the code, mints a session, and returns the product redirect URL (plus an optional Set-Cookie value in cookie mode).
type OAuthSocialCallbackResult ¶
type OAuthSocialCallbackResult struct {
RedirectURL string
// SetCookie carries the session cookies (access + refresh) to set in cookie
// mode; each entry is a full Set-Cookie header value.
SetCookie []string
}
OAuthSocialCallbackResult is the outcome of a social-login callback: the URL to redirect the browser to and, in cookie mode, the Set-Cookie header value.
type OAuthSocialExchangeCmd ¶
OAuthSocialExchangeCmd exchanges a one-time OAuth authorization code for a session. ProjectID scopes the exchange to the client's project; CodeVerifier carries the optional PKCE verifier.
type OAuthSocialLinkCallbackCmd ¶
type OAuthSocialLinkCallbackCmd struct {
AccountID string
ProjectID string
Provider string
Code string
State string
Error string
CodeVerifier string // optional PKCE verifier paired with the StartLink challenge
RedirectTo string // product URL to bounce the browser back to after linking
}
OAuthSocialLinkCallbackCmd carries the provider callback for an account-link flow; the adapter attaches the identity and returns the product redirect URL.
type OAuthSocialLinkStartCmd ¶
type OAuthSocialLinkStartCmd struct {
AccountID string
ProjectID string
Provider string
RedirectTo string
State string
}
OAuthSocialLinkStartCmd begins linking a provider identity to an already authenticated account. AccountID comes from the principal, never the request.
type OAuthSocialStartCmd ¶
type OAuthSocialStartCmd struct {
ProjectID string
Provider string
RedirectTo string
State string
CodeChallenge string
Prompt string
LoginHint string
}
OAuthSocialStartCmd begins a browser-driven social login: the adapter builds the provider authorize URL (carrying state/PKCE/prompt hints) and returns it for a 302 redirect. RedirectTo is the product URL the provider callback will ultimately bounce the user back to.
type OIDCAuthorizeCmd ¶
type OIDCAuthorizeCmd struct {
ClientID string
ResponseType string
RedirectURI string
Scope string
State string
CodeChallenge string
Nonce string
Prompt string
RequestURI string
}
OIDCAuthorizeCmd is the front-channel /oauth2/authorize request. It is a public operation: the client is identified by ClientID and the request is scoped to that client's project. The adapter validates the client, builds an interaction and returns the redirect URL the user-agent must follow (to the login/consent UI, or back to the client with code/error).
type OIDCBackchannelLogoutCmd ¶
type OIDCBackchannelLogoutCmd struct {
LogoutToken string
}
OIDCBackchannelLogoutCmd carries the back-channel logout token (RFC) the OP receives. It is public; the adapter validates the logout_token and terminates the referenced sessions.
type OIDCConsentCmd ¶
type OIDCConsentCmd struct {
InteractionID string
AccountID string
SessionID string
GrantedScopes []string
Remember bool
}
OIDCConsentCmd records the resource-owner's consent decision for an OIDC authorization interaction. AccountID and SessionID identify the authenticated caller (taken from the principal, never the body) and let the adapter verify the interaction belongs to this session before recording consent. Remember persists the grant so the client is not prompted again.
type OIDCDeviceAuthorization ¶
type OIDCDeviceAuthorization struct {
DeviceCode string
UserCode string
VerificationURI string
VerificationURIComplete string
ExpiresIn int
Interval int
}
OIDCDeviceAuthorization is the device authorization response (RFC 8628).
type OIDCDeviceAuthorizationCmd ¶
OIDCDeviceAuthorizationCmd is the /oauth2/device_authorization request (RFC 8628). It is client-authenticated.
type OIDCDeviceDecisionCmd ¶
type OIDCDeviceDecisionCmd struct {
ProjectID string
UserCode string
AccountID string
SessionID string
}
OIDCDeviceDecisionCmd records a logged-in user's approve/deny decision for a pending device authorization. AccountID/SessionID come from the principal.
type OIDCDevicePending ¶
type OIDCDevicePending struct {
ClientID string
ClientMap map[string]any
Scopes []string
ExpiresAt time.Time
}
OIDCDevicePending is the pending device authorization shown to the user at the verification UI before they approve or deny it.
type OIDCDeviceUserCode ¶
OIDCDeviceUserCode identifies a pending device authorization by its user-facing code, scoped to the project that owns the requesting client.
type OIDCIntrospectCmd ¶
type OIDCIntrospectCmd struct {
ProjectID string // request tenant (authenticated client), NOT the token
Env string
Token string
}
OIDCIntrospectCmd is the /oauth2/introspect request (RFC 7662). It is client-authenticated. The adapter returns the introspection response map, including the mandatory "active" flag.
type OIDCLogoutCmd ¶
OIDCLogoutCmd is the front-channel RP-initiated logout request (/oauth2/logout). It is public. The adapter terminates the session referenced by IDTokenHint and returns the post-logout redirect URL.
type OIDCParCmd ¶
type OIDCParCmd struct {
ResponseType string
ClientID string
RedirectURI string
Scope string
State string
CodeChallenge string
CodeChallengeMethod string
Nonce string
ResponseMode string
Prompt string
LoginHint string
Request string
ClientAssertionType string
ClientAssertion string
}
OIDCParCmd is a pushed authorization request (RFC 9126). It mirrors the authorization request parameters and is client-authenticated. The adapter stores the request and returns a request_uri reference plus its lifetime.
type OIDCParResult ¶
OIDCParResult is the result of a pushed authorization request: an opaque request_uri the client passes to /oauth2/authorize, and its lifetime in seconds.
type OIDCRejectCmd ¶
OIDCRejectCmd cancels an OIDC authorization interaction. It is a public operation (no authenticated caller): Error and ErrorDescription carry the OAuth2 error payload that is propagated back to the client via the redirect.
type OIDCRevokeCmd ¶
type OIDCRevokeCmd struct {
ProjectID string // request tenant (authenticated client), NOT the token
Env string
Token string
TokenTypeHint string
}
OIDCRevokeCmd is the /oauth2/revoke request (RFC 7009). It is client-authenticated. TokenTypeHint is optional.
type OIDCTokenCmd ¶
type OIDCTokenCmd struct {
ProjectID string // request tenant (authenticated client), NOT the token
Env string
GrantType string
Code string
RedirectURI string
CodeVerifier string
RefreshToken string
ClientID string
ClientSecret string
DeviceCode string
}
OIDCTokenCmd is the /oauth2/token request (RFC 6749 + extensions). It is a client-authenticated, public-facing endpoint: the client is identified by ClientID/ClientSecret in the body (or via HTTP basic auth at the adapter). The adapter dispatches on GrantType and returns the raw token response map.
type OperatorAdminToken ¶
type OperatorAdminToken struct {
ID string
ProjectID string
Name string
Scopes []string
CreatedAt time.Time
ExpiresAt time.Time
Revoked bool
}
OperatorAdminToken is a read model describing an admin token minted for a project, returned by the /mgmt admin-tokens listing.
type OperatorAdminTokenCmd ¶
type OperatorAdminTokenCmd struct {
ProjectID string
Name string
Scopes []string
ExpiresAt time.Time
}
OperatorAdminTokenCmd carries the operator request to mint a project-admin token. Empty ExpiresAt means the adapter applies its default TTL.
type OperatorConfigCmd ¶
OperatorConfigCmd carries a free-form declarative project configuration document for the config plan/apply operations. Config is intentionally schemaless at this layer; the adapter validates it.
type OperatorFeaturesCmd ¶
OperatorFeaturesCmd is the operator-scoped feature-flag patch for a project.
type OperatorProjectPatchCmd ¶
type OperatorProjectPatchCmd struct {
ProjectID string
Name string
Slug string
DefaultLocale string
}
OperatorProjectPatchCmd is the operator-scoped partial update of a project. Only the named scalar fields are mutable through /mgmt; empty strings are treated as "no change" by the adapter.
type PlatformCsrfToken ¶
type PlatformCsrfToken struct {
Token string
}
PlatformCsrfToken is the result of issuing a CSRF token for a client.
type Principal ¶
type Principal struct {
Kind PrincipalKind
AccountID string // the user, for PrincipalUser
ProjectID string
Environment string
SessionID string
ClientID string
ConnectionID string // for PrincipalSCIM
Scopes []string
AAL int
}
Principal is the authenticated subject a SecurityHandler resolves from a credential and carries in the request context. Handlers read it instead of re-parsing tokens.
type PrincipalKind ¶
type PrincipalKind string
PrincipalKind is the kind of authenticated caller.
const ( PrincipalUser PrincipalKind = "user" // bearerAuth — end-user access token PrincipalAdmin PrincipalKind = "admin" // adminToken — project admin PrincipalOperator PrincipalKind = "operator" // masterKey PrincipalService PrincipalKind = "service" // serviceToken / API key PrincipalSCIM PrincipalKind = "scim" // scimToken PrincipalClient PrincipalKind = "client" // OAuth client (client_secret_basic) )
type ProfileUpdateCmd ¶
type ProfileUpdateCmd struct {
ProjectID string
AccountID string
Name string
AvatarURL string
Locale string
}
func (ProfileUpdateCmd) Validate ¶
func (c ProfileUpdateCmd) Validate() error
Validate checks profile-update invariants.
type ProjectCmd ¶
func (ProjectCmd) Validate ¶
func (c ProjectCmd) Validate() error
Validate checks project-create invariants.
type PublicConfig ¶
type PublicConfig struct {
ProjectName string
Methods []string
Providers []OAuthProvider
Locales []string
DefaultLocale string
ConsentDocuments []ConsentDocument
}
type RegisterCmd ¶
type RegisterCmd struct {
ProjectID string
Email string
Phone string
Password string
Name string
Consents []AccountConsentAcceptance
}
func (RegisterCmd) Validate ¶
func (c RegisterCmd) Validate() error
Validate checks sign-up invariants: an identifier is required.
type ScimToken ¶
type ScimToken struct {
ID string
ProjectID string
ConnectionID string
Name string
ExpiresAt time.Time
}
ScimToken is a provisioning credential bound to an SSO connection. The secret is returned only at creation time and is never persisted in clear.
type ServiceAccount ¶
type ServiceAccountCmd ¶
type WebAuthnCeremonyData ¶
type WebAuthnCeremonyData struct {
PublicKey map[string]any `json:"publicKey,omitempty"`
Session []byte `json:"session,omitempty"`
AccountID string `json:"accountId,omitempty"`
}
WebAuthnCeremonyData is the persisted state of an in-flight WebAuthn ceremony. It is marshalled into the iam_challenges `data` jsonb column. PublicKey holds the publicKey credential options surfaced to the browser (also mirrored on the returned Challenge), while Session is the opaque marshalled go-webauthn SessionData (challenge bytes, RP id, allowed credentials, user verification) the library requires to verify the matching Finish* response. AccountID scopes a registration ceremony to its owner.
type WebAuthnCredential ¶
type WebAuthnRenameCredentialCmd ¶
WebAuthnRenameCredentialCmd renames a stored passkey/WebAuthn credential. The AccountID scopes the operation to the caller, preventing cross-account access.
type WebAuthnStoredCredential ¶
type WebAuthnStoredCredential struct {
Credential WebAuthnCredential `json:"credential"`
Library []byte `json:"library,omitempty"`
}
WebAuthnStoredCredential is the persisted form of a registered passkey. The public, display-facing fields live on Credential; Library is the opaque marshalled go-webauthn Credential (id, COSE public key, sign count, AAGUID, flags, attestation) the library needs to verify subsequent assertions. It is marshalled into the iam_webauthn_credentials `data` jsonb column.