domain

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperatorAuditActionEmailTemplateSaved            = "email_template.saved"
	OperatorAuditActionEmailTemplateRestoredBuiltIn  = "email_template.restored_builtin"
	OperatorAuditActionEmailTemplateDeliveryEnabled  = "email_template.delivery_enabled"
	OperatorAuditActionEmailTemplateDeliveryDisabled = "email_template.delivery_disabled"
	OperatorAuditActionRuntimeSettingSet             = "runtime_setting.set"
	OperatorAuditActionRuntimeSettingCleared         = "runtime_setting.cleared"
	OperatorAuditResourceEmailTemplate               = "email_template"
	OperatorAuditResourceRuntimeSetting              = "runtime_setting"
)
View Source
const (
	SecurityEventReasonInvalidCredentials  = "invalid_credentials"
	SecurityEventReasonInvalidAssertion    = "invalid_assertion"
	SecurityEventReasonAccessPolicy        = "access_policy"
	SecurityEventReasonAccountLinkRequired = "account_link_required"
	SecurityEventReasonProviderDisabled    = "provider_disabled"
	SecurityEventReasonAudienceForbidden   = "audience_forbidden"
	SecurityEventReasonUserDisabled        = "user_disabled"
	SecurityEventReasonMethodUnavailable   = "authentication_method_unavailable"
	SecurityEventReasonRefreshTokenReuse   = "refresh_token_reuse"
	SecurityEventReasonUserRequested       = "user_requested"
	SecurityEventReasonSecurityContainment = "security_containment"
)

Variables

This section is empty.

Functions

func IsSecurityEventType added in v0.22.0

func IsSecurityEventType(value string) bool

Types

type AdminAuditEvent added in v0.1.23

type AdminAuditEvent struct {
	ID uuid.UUID

	CreatedAt time.Time

	ActorUserID *uuid.UUID
	ActorEmail  *string
	Action      string

	TargetUserID *uuid.UUID
	TargetEmail  *string
	Metadata     json.RawMessage

	IP        *string
	UserAgent *string
}

type AllowedEmail added in v0.1.13

type AllowedEmail struct {
	ID        uuid.UUID
	CreatedAt time.Time
	UpdatedAt time.Time
	Email     string
}

type AppleCredential added in v0.22.0

type AppleCredential struct {
	AuthProviderID        uuid.UUID
	EncryptionKeyID       string
	EncryptedRefreshToken []byte
	CreatedAt             time.Time
	UpdatedAt             time.Time
}

type AppleTokenRevocation added in v0.22.0

type AppleTokenRevocation struct {
	ID                    uuid.UUID
	AuthProviderID        *uuid.UUID
	EncryptionContext     uuid.UUID
	EncryptionKeyID       string
	EncryptedRefreshToken []byte
	AttemptCount          int
	NextAttemptAt         time.Time
	LastError             *string
	CreatedAt             time.Time
	UpdatedAt             time.Time
}

type AuthProvider

type AuthProvider struct {
	// ID is nil only before persistence.
	// After loading or creating a authProvider, ID is always non-nil.
	ID        uuid.UUID
	CreatedAt time.Time
	UpdatedAt time.Time

	UserID   uuid.UUID
	Provider Provider

	ProviderUserID *string
	PasswordHash   *string
}

type AuthenticationChallenge added in v0.22.0

type AuthenticationChallenge struct {
	ID        uuid.UUID
	UserID    uuid.UUID
	SessionID uuid.UUID

	CreatedAt  time.Time
	ExpiresAt  time.Time
	ConsumedAt *time.Time

	AuthenticationMethod AuthenticationMethod
}

func (AuthenticationChallenge) IsConsumed added in v0.22.0

func (c AuthenticationChallenge) IsConsumed() bool

func (AuthenticationChallenge) IsExpired added in v0.22.0

func (c AuthenticationChallenge) IsExpired(now time.Time) bool

type AuthenticationMethod added in v0.22.0

type AuthenticationMethod string
const (
	AuthenticationMethodPassword AuthenticationMethod = "password"
	AuthenticationMethodPasskey  AuthenticationMethod = "passkey"
	AuthenticationMethodGoogle   AuthenticationMethod = "google"
	AuthenticationMethodApple    AuthenticationMethod = "apple"
)

type Challenge added in v0.1.12

type Challenge struct {
	ID uuid.UUID

	CreatedAt  time.Time
	UpdatedAt  time.Time
	ExpiresAt  time.Time
	ConsumedAt *time.Time

	Purpose      ChallengePurpose
	Email        string
	AttemptCount int
	MaxAttempts  int

	ResendCount int
	MaxResends  int
	LastSentAt  *time.Time

	MinimumResendInterval    time.Duration
	HasMinimumResendInterval bool
}

func (Challenge) HasAttemptsRemaining added in v0.1.12

func (c Challenge) HasAttemptsRemaining() bool

func (Challenge) IsConsumed added in v0.1.12

func (c Challenge) IsConsumed() bool

func (Challenge) IsExpired added in v0.1.12

func (c Challenge) IsExpired(now time.Time) bool

type ChallengePurpose added in v0.1.12

type ChallengePurpose string
const (
	ChallengePurposeSignup            ChallengePurpose = "signup"
	ChallengePurposePasswordReset     ChallengePurpose = "password_reset"
	ChallengePurposeEmailChange       ChallengePurpose = "email_change"
	ChallengePurposeEmailVerification ChallengePurpose = "email_verification"
)

type EmailJob added in v0.1.12

type EmailJob struct {
	ID          uuid.UUID
	ChallengeID *uuid.UUID

	CreatedAt time.Time
	UpdatedAt time.Time

	ToEmail             string
	Template            EmailTemplate
	TemplateData        []byte
	Status              EmailJobStatus
	AttemptCount        int
	ProcessingStartedAt *time.Time
	LastError           *string
	NextAttemptAt       time.Time
	DeliveryDeadlineAt  time.Time
	TerminalReason      *string
	FailedAt            *time.Time
	SentAt              *time.Time
}

type EmailJobStatus added in v0.1.12

type EmailJobStatus string
const (
	EmailJobStatusPending    EmailJobStatus = "pending"
	EmailJobStatusProcessing EmailJobStatus = "processing"
	EmailJobStatusSent       EmailJobStatus = "sent"
	EmailJobStatusFailed     EmailJobStatus = "failed"
)

type EmailTemplate added in v0.1.12

type EmailTemplate string
const (
	EmailTemplateSignupCode                       EmailTemplate = "signup_code"
	EmailTemplatePasswordResetCode                EmailTemplate = "password_reset_code"
	EmailTemplateEmailChangeCode                  EmailTemplate = "email_change_code"
	EmailTemplateOrganizationInvite               EmailTemplate = "organization_invitation"
	EmailTemplateAccountCreated                   EmailTemplate = "account_created"
	EmailTemplateNewSignIn                        EmailTemplate = "new_sign_in"
	EmailTemplateAuthMethodAdded                  EmailTemplate = "auth_method_added"
	EmailTemplateAuthMethodRemoved                EmailTemplate = "auth_method_removed"
	EmailTemplateSuspiciousPasskeyActivity        EmailTemplate = "suspicious_passkey_activity"
	EmailTemplatePasswordChanged                  EmailTemplate = "password_changed"
	EmailTemplateEmailChangedOldAddress           EmailTemplate = "email_changed_old_address"
	EmailTemplateEmailChangedNewAddress           EmailTemplate = "email_changed_new_address"
	EmailTemplateAccountDisabled                  EmailTemplate = "account_disabled"
	EmailTemplateAccountEnabled                   EmailTemplate = "account_enabled"
	EmailTemplateAdminAccessChanged               EmailTemplate = "admin_access_changed"
	EmailTemplateOrganizationInvitationAccepted   EmailTemplate = "organization_invitation_accepted"
	EmailTemplateOrganizationInvitationRevoked    EmailTemplate = "organization_invitation_revoked"
	EmailTemplateOrganizationMembershipRemoved    EmailTemplate = "organization_membership_removed"
	EmailTemplateOrganizationRoleChanged          EmailTemplate = "organization_role_changed"
	EmailTemplateOrganizationOwnershipTransferred EmailTemplate = "organization_ownership_transferred"
	EmailTemplateOrganizationDeleted              EmailTemplate = "organization_deleted"
)

func SupportedEmailTemplates added in v0.20.0

func SupportedEmailTemplates() []EmailTemplate

SupportedEmailTemplates returns every email template understood by Core in its stable display order.

type EmailTemplateDeliverySetting added in v0.21.0

type EmailTemplateDeliverySetting struct {
	Template EmailTemplate
	Enabled  bool

	CreatedAt time.Time
	UpdatedAt time.Time

	UpdatedByUserID *uuid.UUID
}

EmailTemplateDeliverySetting is an explicit operator choice for whether new jobs of a template type may be enqueued. A missing setting means enabled.

type EmailTemplateOverride added in v0.20.0

type EmailTemplateOverride struct {
	Template EmailTemplate

	CreatedAt time.Time
	UpdatedAt time.Time

	SubjectTemplate string
	TextTemplate    string
	HTMLTemplate    string
	Revision        int64
	UpdatedByUserID *uuid.UUID
}

EmailTemplateOverride is the persisted operator customization for one Core-owned email template. A missing override means the built-in template is effective.

type EmailTemplateVersion added in v0.20.0

type EmailTemplateVersion struct {
	Template EmailTemplate
	Version  int64

	CreatedAt time.Time

	SubjectTemplate string
	TextTemplate    string
	HTMLTemplate    string
	CreatedByUserID *uuid.UUID
}

EmailTemplateVersion is an immutable snapshot created whenever an operator successfully saves or restores a customized template.

type EmailVerificationTransaction added in v0.22.0

type EmailVerificationTransaction struct {
	ID                   uuid.UUID
	CreatedAt            time.Time
	UserID               uuid.UUID
	OriginalSessionID    uuid.UUID
	Audience             string
	AuthenticationMethod AuthenticationMethod
	ReturnTo             string
	ExpiresAt            time.Time
	ConsumedAt           *time.Time
	ChallengeID          *uuid.UUID
	TargetEmail          *string
}

func (EmailVerificationTransaction) IsActive added in v0.22.0

func (t EmailVerificationTransaction) IsActive(now time.Time) bool

type OperatorAuditEvent added in v0.20.0

type OperatorAuditEvent struct {
	ID        uuid.UUID
	CreatedAt time.Time

	ActorUserID *uuid.UUID
	ActorEmail  *string

	Action       string
	ResourceType string
	ResourceID   string
	Metadata     json.RawMessage
}

OperatorAuditEvent records a control-plane mutation. Metadata is limited to non-sensitive identifiers and change summaries rather than resource bodies.

type Organization added in v0.1.24

type Organization struct {
	ID        uuid.UUID
	CreatedAt time.Time
	UpdatedAt time.Time

	Name            string
	Kind            OrganizationKind
	CreatedByUserID *uuid.UUID
}

type OrganizationInvitation added in v0.1.24

type OrganizationInvitation struct {
	ID        uuid.UUID
	CreatedAt time.Time
	UpdatedAt time.Time

	OrganizationID  uuid.UUID
	Email           string
	Role            OrganizationRole
	Metadata        json.RawMessage
	TokenHash       string
	InvitedByUserID *uuid.UUID

	ExpiresAt time.Time

	AcceptedAt       *time.Time
	AcceptedByUserID *uuid.UUID
	RevokedAt        *time.Time
	RevokedByUserID  *uuid.UUID
}

func (OrganizationInvitation) Status added in v0.1.24

type OrganizationInvitationStatus added in v0.1.24

type OrganizationInvitationStatus string
const (
	OrganizationInvitationStatusPending  OrganizationInvitationStatus = "pending"
	OrganizationInvitationStatusAccepted OrganizationInvitationStatus = "accepted"
	OrganizationInvitationStatusRevoked  OrganizationInvitationStatus = "revoked"
	OrganizationInvitationStatusExpired  OrganizationInvitationStatus = "expired"
)

type OrganizationKind added in v0.1.24

type OrganizationKind string
const (
	OrganizationKindPersonal OrganizationKind = "personal"
	OrganizationKindTeam     OrganizationKind = "team"
)

type OrganizationMember added in v0.1.25

type OrganizationMember struct {
	User       User
	Membership OrganizationMembership
}

type OrganizationMembership added in v0.1.24

type OrganizationMembership struct {
	OrganizationID uuid.UUID
	UserID         uuid.UUID

	Role OrganizationRole

	CreatedAt time.Time
	UpdatedAt time.Time
}

type OrganizationRole added in v0.1.24

type OrganizationRole string
const (
	OrganizationRoleOwner  OrganizationRole = "owner"
	OrganizationRoleAdmin  OrganizationRole = "admin"
	OrganizationRoleMember OrganizationRole = "member"
)

type Passkey added in v0.1.21

type Passkey struct {
	ID        uuid.UUID
	UserID    uuid.UUID
	CreatedAt time.Time
	UpdatedAt time.Time

	CredentialID      []byte
	PublicKey         []byte
	AttestationType   string
	AttestationFormat string
	Transport         []string
	AAGUID            *uuid.UUID
	SignCount         uint32
	CloneWarning      bool
	RestrictedAt      *time.Time
	Name              string
	LastUsedAt        *time.Time

	UserPresent    bool
	UserVerified   bool
	BackupEligible bool
	BackupState    bool
}

type PendingEmailChange added in v0.1.15

type PendingEmailChange struct {
	ID                  uuid.UUID
	CreatedAt           time.Time
	ChallengeID         uuid.UUID
	UserID              uuid.UUID
	InitiatingSessionID uuid.UUID
	OldEmail            string
	NewEmail            string
}

type PendingPasswordReset added in v0.1.14

type PendingPasswordReset struct {
	ID           uuid.UUID
	CreatedAt    time.Time
	ChallengeID  uuid.UUID
	UserID       uuid.UUID
	PasswordHash string
}
type PendingProviderLink struct {
	ID        uuid.UUID
	CreatedAt time.Time

	UserID      uuid.UUID
	SessionID   *uuid.UUID
	ChallengeID *uuid.UUID
	Provider    Provider

	ProviderUserID        *string
	ProviderEmail         *string
	ProviderEmailVerified bool
	Purpose               PendingProviderLinkPurpose

	ExpiresAt  time.Time
	ConsumedAt *time.Time
}

type PendingProviderLinkPurpose added in v0.1.19

type PendingProviderLinkPurpose string
const (
	PendingProviderLinkPurposeAuthenticatedLink PendingProviderLinkPurpose = "authenticated_link"
	PendingProviderLinkPurposeAccountRecovery   PendingProviderLinkPurpose = "account_recovery_link"
)

type PendingSignupAction added in v0.1.12

type PendingSignupAction struct {
	ID          uuid.UUID
	ChallengeID uuid.UUID

	CreatedAt time.Time
	UpdatedAt time.Time

	Email        string
	Username     string
	PasswordHash string
	InvitationID *uuid.UUID
}

type Provider

type Provider string
const (
	ProviderPassword Provider = "password"
	ProviderGoogle   Provider = "google"
	ProviderApple    Provider = "apple"
)

type RefreshToken

type RefreshToken struct {
	ID        uuid.UUID
	CreatedAt time.Time

	SessionID      uuid.UUID
	OrganizationID uuid.UUID
	TokenHash      string

	ExpiresAt  time.Time
	ConsumedAt *time.Time
}

type SecurityEvent added in v0.22.0

type SecurityEvent struct {
	ID                   uuid.UUID              `json:"id"`
	CreatedAt            time.Time              `json:"created_at"`
	Type                 SecurityEventType      `json:"type"`
	Outcome              SecurityEventOutcome   `json:"outcome"`
	ReasonCode           string                 `json:"reason_code,omitempty"`
	ActorType            SecurityEventActorType `json:"actor_type"`
	ActorUserID          *uuid.UUID             `json:"actor_user_id,omitempty"`
	UserID               *uuid.UUID             `json:"subject_user_id,omitempty"`
	SessionID            *uuid.UUID             `json:"session_id,omitempty"`
	OrganizationID       *uuid.UUID             `json:"organization_id,omitempty"`
	PasskeyID            *uuid.UUID             `json:"passkey_id,omitempty"`
	AuthenticationMethod AuthenticationMethod   `json:"authentication_method,omitempty"`
	Response             string                 `json:"response,omitempty"`
}

SecurityEvent contains only allowlisted, non-secret security context. Raw identifiers, tokens, credentials, email addresses, IP addresses and user agents must never be added to this record.

type SecurityEventActorType added in v0.22.0

type SecurityEventActorType string
const (
	SecurityEventActorAnonymous SecurityEventActorType = "anonymous"
	SecurityEventActorUser      SecurityEventActorType = "user"
	SecurityEventActorSystem    SecurityEventActorType = "system"
)

type SecurityEventOutcome added in v0.22.0

type SecurityEventOutcome string
const (
	SecurityEventOutcomeSuccess SecurityEventOutcome = "success"
	SecurityEventOutcomeDenied  SecurityEventOutcome = "denied"
	SecurityEventOutcomeFailure SecurityEventOutcome = "failure"
)

type SecurityEventType added in v0.22.0

type SecurityEventType string
const (
	SecurityEventAuthenticationLogin           SecurityEventType = "authentication.login"
	SecurityEventAuthenticationReauthenticated SecurityEventType = "authentication.reauthenticated"
	SecurityEventSessionRefresh                SecurityEventType = "session.refresh"
	SecurityEventSessionRefreshTokenReuse      SecurityEventType = "session.refresh_token_reuse"
	SecurityEventSessionLogout                 SecurityEventType = "session.logout"
	SecurityEventSessionRevoked                SecurityEventType = "session.revoked"
	SecurityEventCredentialPasswordAdded       SecurityEventType = "credential.password_added"
	SecurityEventCredentialPasswordChanged     SecurityEventType = "credential.password_changed"
	SecurityEventCredentialPasswordReset       SecurityEventType = "credential.password_reset"
	SecurityEventCredentialProviderLinked      SecurityEventType = "credential.provider_linked"
	SecurityEventCredentialProviderChanged     SecurityEventType = "credential.provider_changed"
	SecurityEventCredentialProviderRemoved     SecurityEventType = "credential.provider_removed"
	SecurityEventCredentialPasskeyAdded        SecurityEventType = "credential.passkey_added"
	SecurityEventCredentialPasskeyRemoved      SecurityEventType = "credential.passkey_removed"
	SecurityEventAccountEmailChanged           SecurityEventType = "account.email_changed"
	SecurityEventPasskeyCloneWarning           SecurityEventType = "passkey.clone_warning"
)

func SecurityEventTypes added in v0.22.0

func SecurityEventTypes() []SecurityEventType

func StandardSecurityEventTypes added in v0.22.0

func StandardSecurityEventTypes() []SecurityEventType

type Session

type Session struct {
	ID                   uuid.UUID
	UserID               uuid.UUID
	ActiveOrganizationID uuid.UUID

	CreatedAt time.Time
	UpdatedAt time.Time

	ExpiresAt time.Time
	RevokedAt *time.Time

	AuthenticatedAt      *time.Time
	AuthenticationMethod AuthenticationMethod

	UserAgent string
}

type User

type User struct {
	ID        uuid.UUID
	CreatedAt time.Time
	UpdatedAt time.Time

	DisabledAt *time.Time

	Email           string
	EmailVerifiedAt *time.Time
	Username        string
}

type VerificationCode added in v0.1.12

type VerificationCode struct {
	ID          uuid.UUID
	ChallengeID uuid.UUID

	CreatedAt time.Time
	ExpiresAt time.Time

	CodeHash string
}

type WebAuthnChallenge added in v0.1.21

type WebAuthnChallenge struct {
	ID        uuid.UUID
	CreatedAt time.Time

	UserID      *uuid.UUID
	SessionID   *uuid.UUID
	Purpose     WebAuthnChallengePurpose
	Challenge   string
	SessionData []byte
	ExpiresAt   time.Time
	ConsumedAt  *time.Time
}

type WebAuthnChallengePurpose added in v0.1.21

type WebAuthnChallengePurpose string
const (
	WebAuthnChallengePurposeRegistration     WebAuthnChallengePurpose = "registration"
	WebAuthnChallengePurposeAuthentication   WebAuthnChallengePurpose = "authentication"
	WebAuthnChallengePurposeReauthentication WebAuthnChallengePurpose = "reauthentication"
)

type WebhookEvent added in v0.1.27

type WebhookEvent struct {
	ID        string
	CreatedAt time.Time
	UpdatedAt time.Time

	EventType string
	Payload   []byte
	Status    WebhookEventStatus

	AttemptCount        int
	NextAttemptAt       time.Time
	ProcessingStartedAt *time.Time
	LastError           *string
	DeliveredAt         *time.Time
}

type WebhookEventStatus added in v0.1.27

type WebhookEventStatus string
const (
	WebhookEventStatusPending    WebhookEventStatus = "pending"
	WebhookEventStatusProcessing WebhookEventStatus = "processing"
	WebhookEventStatusDelivered  WebhookEventStatus = "delivered"
	WebhookEventStatusFailed     WebhookEventStatus = "failed"
)

Jump to

Keyboard shortcuts

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