repository

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSearchNotSupported = audit.InvalidFilter("search", "full-text search not supported for this database")

Functions

func NewDatabaseRetryStorage added in v0.0.7

func NewDatabaseRetryStorage(repo NotificationQueueRepository) notification.RetryStorage

NewDatabaseRetryStorage creates a new database-backed retry storage

func NewEnvironmentRepository

func NewEnvironmentRepository(db *bun.DB) *environmentRepository

NewEnvironmentRepository creates a new environment repository

func NewFormsRepository

func NewFormsRepository(db *bun.DB) forms.Repository

NewFormsRepository creates a new forms repository

func NewNotificationRepository

func NewNotificationRepository(db *bun.DB) notification.Repository

NewNotificationRepository creates a new notification repository

func NewVerificationRepository added in v0.0.6

func NewVerificationRepository(db *bun.DB) *verificationRepository

NewVerificationRepository creates a new verification repository

func NewWebhookRepository

func NewWebhookRepository(db *bun.DB) webhook.Repository

NewWebhookRepository creates a new webhook repository

Types

type APIKeyRepository

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

APIKeyRepository handles API key database operations Updated for V2 architecture: App → Environment → Organization

func NewAPIKeyRepository

func NewAPIKeyRepository(db *bun.DB) *APIKeyRepository

NewAPIKeyRepository creates a new API key repository

func (*APIKeyRepository) CleanupExpiredAPIKeys

func (r *APIKeyRepository) CleanupExpiredAPIKeys(ctx context.Context) (int, error)

CleanupExpiredAPIKeys removes expired API keys

func (*APIKeyRepository) CountAPIKeys

func (r *APIKeyRepository) CountAPIKeys(ctx context.Context, appID xid.ID, envID *xid.ID, orgID *xid.ID, userID *xid.ID) (int, error)

CountAPIKeys counts API keys with flexible filtering

func (*APIKeyRepository) CreateAPIKey

func (r *APIKeyRepository) CreateAPIKey(ctx context.Context, apiKey *schema.APIKey) error

CreateAPIKey creates a new API key

func (*APIKeyRepository) DeactivateAPIKey

func (r *APIKeyRepository) DeactivateAPIKey(ctx context.Context, id xid.ID) error

DeactivateAPIKey deactivates an API key without deleting it

func (*APIKeyRepository) DeleteAPIKey

func (r *APIKeyRepository) DeleteAPIKey(ctx context.Context, id xid.ID) error

DeleteAPIKey soft deletes an API key

func (*APIKeyRepository) FindAPIKeyByID

func (r *APIKeyRepository) FindAPIKeyByID(ctx context.Context, id xid.ID) (*schema.APIKey, error)

FindAPIKeyByID finds an API key by ID

func (*APIKeyRepository) FindAPIKeyByPrefix

func (r *APIKeyRepository) FindAPIKeyByPrefix(ctx context.Context, prefix string) (*schema.APIKey, error)

FindAPIKeyByPrefix finds an API key by prefix

func (*APIKeyRepository) ListAPIKeys

ListAPIKeys lists API keys with filtering and pagination

func (*APIKeyRepository) UpdateAPIKey

func (r *APIKeyRepository) UpdateAPIKey(ctx context.Context, apiKey *schema.APIKey) error

UpdateAPIKey updates an API key

func (*APIKeyRepository) UpdateAPIKeyUsage

func (r *APIKeyRepository) UpdateAPIKeyUsage(ctx context.Context, id xid.ID, ip, userAgent string) error

UpdateAPIKeyUsage updates the usage statistics for an API key

type APIKeyRoleRepository

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

APIKeyRoleRepository handles API key to role assignments

func NewAPIKeyRoleRepository

func NewAPIKeyRoleRepository(db *bun.DB) *APIKeyRoleRepository

NewAPIKeyRoleRepository creates a new API key role repository

func (*APIKeyRoleRepository) AssignRole

func (r *APIKeyRoleRepository) AssignRole(ctx context.Context, apiKeyID, roleID xid.ID, orgID *xid.ID, createdBy *xid.ID) error

AssignRole assigns a role to an API key

func (*APIKeyRoleRepository) BulkAssignRoles

func (r *APIKeyRoleRepository) BulkAssignRoles(ctx context.Context, apiKeyID xid.ID, roleIDs []xid.ID, orgID *xid.ID, createdBy *xid.ID) error

BulkAssignRoles assigns multiple roles to an API key in a single transaction

func (*APIKeyRoleRepository) BulkUnassignRoles

func (r *APIKeyRoleRepository) BulkUnassignRoles(ctx context.Context, apiKeyID xid.ID, roleIDs []xid.ID, orgID *xid.ID) error

BulkUnassignRoles removes multiple roles from an API key in a single transaction

func (*APIKeyRoleRepository) GetAPIKeysWithRole

func (r *APIKeyRoleRepository) GetAPIKeysWithRole(ctx context.Context, roleID xid.ID, orgID *xid.ID) ([]*schema.APIKey, error)

GetAPIKeysWithRole retrieves all API keys that have a specific role

func (*APIKeyRoleRepository) GetCreatorPermissions

func (r *APIKeyRoleRepository) GetCreatorPermissions(ctx context.Context, creatorID xid.ID, orgID *xid.ID) ([]*schema.Permission, error)

GetCreatorPermissions retrieves the permissions of the user who created the API key

func (*APIKeyRoleRepository) GetCreatorRoles

func (r *APIKeyRoleRepository) GetCreatorRoles(ctx context.Context, creatorID xid.ID, orgID *xid.ID) ([]*schema.Role, error)

GetCreatorRoles retrieves the roles of the user who created the API key

func (*APIKeyRoleRepository) GetPermissions

func (r *APIKeyRoleRepository) GetPermissions(ctx context.Context, apiKeyID xid.ID, orgID *xid.ID) ([]*schema.Permission, error)

GetPermissions retrieves all permissions for an API key through its roles

func (*APIKeyRoleRepository) GetRoles

func (r *APIKeyRoleRepository) GetRoles(ctx context.Context, apiKeyID xid.ID, orgID *xid.ID) ([]*schema.Role, error)

GetRoles retrieves all roles assigned to an API key

func (*APIKeyRoleRepository) HasRole

func (r *APIKeyRoleRepository) HasRole(ctx context.Context, apiKeyID, roleID xid.ID, orgID *xid.ID) (bool, error)

HasRole checks if an API key has a specific role

func (*APIKeyRoleRepository) ReplaceRoles

func (r *APIKeyRoleRepository) ReplaceRoles(ctx context.Context, apiKeyID xid.ID, roleIDs []xid.ID, orgID *xid.ID, createdBy *xid.ID) error

ReplaceRoles replaces all roles for an API key with a new set (in a transaction)

func (*APIKeyRoleRepository) UnassignRole

func (r *APIKeyRoleRepository) UnassignRole(ctx context.Context, apiKeyID, roleID xid.ID, orgID *xid.ID) error

UnassignRole removes a role from an API key (soft delete)

type AppRepository

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

AppRepository is a Bun-backed implementation of app repository

func NewAppRepository

func NewAppRepository(db *bun.DB) *AppRepository

func (*AppRepository) AddTeamMember

func (r *AppRepository) AddTeamMember(ctx context.Context, tm *schema.TeamMember) error

AddTeamMember adds a member to a team

func (*AppRepository) CountApps

func (r *AppRepository) CountApps(ctx context.Context) (int, error)

CountApps returns total number of apps

func (*AppRepository) CountMembers

func (r *AppRepository) CountMembers(ctx context.Context, appID xid.ID) (int, error)

CountMembers returns the total number of members in an app

func (*AppRepository) CountTeamMembers

func (r *AppRepository) CountTeamMembers(ctx context.Context, teamID xid.ID) (int, error)

CountTeamMembers returns the total number of members in a team

func (*AppRepository) CountTeams

func (r *AppRepository) CountTeams(ctx context.Context, appID xid.ID) (int, error)

CountTeams returns the total number of teams in an app

func (*AppRepository) CreateApp

func (r *AppRepository) CreateApp(ctx context.Context, app *schema.App) error

func (*AppRepository) CreateInvitation

func (r *AppRepository) CreateInvitation(ctx context.Context, inv *schema.Invitation) error

CreateInvitation creates an invitation

func (*AppRepository) CreateMember

func (r *AppRepository) CreateMember(ctx context.Context, member *schema.Member) error

CreateMember creates a new member

func (*AppRepository) CreateTeam

func (r *AppRepository) CreateTeam(ctx context.Context, team *schema.Team) error

CreateTeam creates a new team

func (*AppRepository) DeleteApp

func (r *AppRepository) DeleteApp(ctx context.Context, id xid.ID) error

func (*AppRepository) DeleteExpiredInvitations

func (r *AppRepository) DeleteExpiredInvitations(ctx context.Context) (int, error)

DeleteExpiredInvitations deletes expired invitations

func (*AppRepository) DeleteInvitation

func (r *AppRepository) DeleteInvitation(ctx context.Context, id xid.ID) error

DeleteInvitation deletes an invitation

func (*AppRepository) DeleteMember

func (r *AppRepository) DeleteMember(ctx context.Context, id xid.ID) error

DeleteMember deletes a member

func (*AppRepository) DeleteTeam

func (r *AppRepository) DeleteTeam(ctx context.Context, id xid.ID) error

DeleteTeam deletes a team

func (*AppRepository) FindAppByID

func (r *AppRepository) FindAppByID(ctx context.Context, id xid.ID) (*schema.App, error)

func (*AppRepository) FindAppBySlug

func (r *AppRepository) FindAppBySlug(ctx context.Context, slug string) (*schema.App, error)

func (*AppRepository) FindInvitationByID

func (r *AppRepository) FindInvitationByID(ctx context.Context, id xid.ID) (*schema.Invitation, error)

FindInvitationByID finds an invitation by ID

func (*AppRepository) FindInvitationByToken

func (r *AppRepository) FindInvitationByToken(ctx context.Context, token string) (*schema.Invitation, error)

FindInvitationByToken finds an invitation by token

func (*AppRepository) FindMember

func (r *AppRepository) FindMember(ctx context.Context, appID, userID xid.ID) (*schema.Member, error)

FindMember finds a member by app ID and user ID (for IsUserMember)

func (*AppRepository) FindMemberByID

func (r *AppRepository) FindMemberByID(ctx context.Context, id xid.ID) (*schema.Member, error)

FindMemberByID finds a member by ID

func (*AppRepository) FindTeamByID

func (r *AppRepository) FindTeamByID(ctx context.Context, id xid.ID) (*schema.Team, error)

FindTeamByID finds a team by ID

func (*AppRepository) FindTeamByName

func (r *AppRepository) FindTeamByName(ctx context.Context, appID xid.ID, name string) (*schema.Team, error)

FindTeamByName finds a team by name within an app

func (*AppRepository) GetPlatformApp

func (r *AppRepository) GetPlatformApp(ctx context.Context) (*schema.App, error)

func (*AppRepository) IsTeamMember

func (r *AppRepository) IsTeamMember(ctx context.Context, teamID, memberID xid.ID) (bool, error)

IsTeamMember checks if a member is part of a team

func (*AppRepository) ListApps

func (*AppRepository) ListInvitations

ListInvitations lists invitations by app with optional status filter and pagination

func (*AppRepository) ListMemberTeams

ListMemberTeams lists all teams a member belongs to with pagination

func (*AppRepository) ListMembers

ListMembers lists members by app with optional filters and pagination

func (*AppRepository) ListMembersByUser

func (r *AppRepository) ListMembersByUser(ctx context.Context, userID xid.ID) ([]*schema.Member, error)

ListMembersByUser lists all memberships for a user across all apps

func (*AppRepository) ListTeamMembers

ListTeamMembers lists members of a team

func (*AppRepository) ListTeams

ListTeams lists teams by app with pagination

func (*AppRepository) RemoveTeamMember

func (r *AppRepository) RemoveTeamMember(ctx context.Context, teamID, memberID xid.ID) error

RemoveTeamMember removes a member from a team

func (*AppRepository) UpdateApp

func (r *AppRepository) UpdateApp(ctx context.Context, app *schema.App) error

func (*AppRepository) UpdateInvitation

func (r *AppRepository) UpdateInvitation(ctx context.Context, inv *schema.Invitation) error

UpdateInvitation updates an invitation

func (*AppRepository) UpdateMember

func (r *AppRepository) UpdateMember(ctx context.Context, member *schema.Member) error

UpdateMember updates a member

func (*AppRepository) UpdateTeam

func (r *AppRepository) UpdateTeam(ctx context.Context, team *schema.Team) error

UpdateTeam updates a team

type AuditRepository

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

AuditRepository implements core audit repository using Bun

func NewAuditRepository

func NewAuditRepository(db *bun.DB) *AuditRepository

NewAuditRepository creates a new audit repository

func (*AuditRepository) Count added in v0.0.9

func (r *AuditRepository) Count(ctx context.Context, filter *audit.ListEventsFilter) (int64, error)

Count returns the count of audit events matching the filter

func (*AuditRepository) Create

Create creates a new audit event

func (*AuditRepository) DeleteOlderThan added in v0.0.9

func (r *AuditRepository) DeleteOlderThan(ctx context.Context, filter *audit.DeleteFilter, before time.Time) (int64, error)

DeleteOlderThan deletes audit events older than the specified time

func (*AuditRepository) Get

Get retrieves an audit event by ID

func (*AuditRepository) GetOldestEvent added in v0.0.9

func (r *AuditRepository) GetOldestEvent(ctx context.Context, filter *audit.ListEventsFilter) (*schema.AuditEvent, error)

GetOldestEvent retrieves the oldest audit event matching the filter

func (*AuditRepository) GetStatisticsByAction added in v0.0.9

func (r *AuditRepository) GetStatisticsByAction(ctx context.Context, filter *audit.StatisticsFilter) ([]*audit.ActionStatistic, error)

GetStatisticsByAction returns aggregated statistics grouped by action

func (*AuditRepository) GetStatisticsByActionAndUser added in v0.0.9

func (r *AuditRepository) GetStatisticsByActionAndUser(ctx context.Context, filter *audit.StatisticsFilter) ([]*audit.ActionUserStatistic, error)

GetStatisticsByActionAndUser returns event counts grouped by action and user

func (*AuditRepository) GetStatisticsByDate added in v0.0.9

func (r *AuditRepository) GetStatisticsByDate(ctx context.Context, filter *audit.StatisticsFilter) ([]*audit.DateStatistic, error)

GetStatisticsByDate returns daily event counts for a date range

func (*AuditRepository) GetStatisticsByDay added in v0.0.9

func (r *AuditRepository) GetStatisticsByDay(ctx context.Context, filter *audit.StatisticsFilter) ([]*audit.DayStatistic, error)

GetStatisticsByDay returns event distribution by day of week

func (*AuditRepository) GetStatisticsByHour added in v0.0.9

func (r *AuditRepository) GetStatisticsByHour(ctx context.Context, filter *audit.StatisticsFilter) ([]*audit.HourStatistic, error)

GetStatisticsByHour returns event distribution by hour of day (0-23)

func (*AuditRepository) GetStatisticsByIPAddress added in v0.0.9

func (r *AuditRepository) GetStatisticsByIPAddress(ctx context.Context, filter *audit.StatisticsFilter) ([]*audit.IPStatistic, error)

GetStatisticsByIPAddress returns event counts grouped by IP address

func (*AuditRepository) GetStatisticsByResource added in v0.0.9

func (r *AuditRepository) GetStatisticsByResource(ctx context.Context, filter *audit.StatisticsFilter) ([]*audit.ResourceStatistic, error)

GetStatisticsByResource returns aggregated statistics grouped by resource

func (*AuditRepository) GetStatisticsByResourceAndAction added in v0.0.9

func (r *AuditRepository) GetStatisticsByResourceAndAction(ctx context.Context, filter *audit.StatisticsFilter) ([]*audit.ResourceActionStatistic, error)

GetStatisticsByResourceAndAction returns event counts grouped by resource and action

func (*AuditRepository) GetStatisticsByUser added in v0.0.9

func (r *AuditRepository) GetStatisticsByUser(ctx context.Context, filter *audit.StatisticsFilter) ([]*audit.UserStatistic, error)

GetStatisticsByUser returns aggregated statistics grouped by user

func (*AuditRepository) GetTimeSeries added in v0.0.9

func (r *AuditRepository) GetTimeSeries(ctx context.Context, filter *audit.TimeSeriesFilter) ([]*audit.TimeSeriesPoint, error)

GetTimeSeries returns event counts over time with configurable intervals

func (*AuditRepository) GetUniqueIPCount added in v0.0.9

func (r *AuditRepository) GetUniqueIPCount(ctx context.Context, filter *audit.StatisticsFilter) (int64, error)

GetUniqueIPCount returns the count of unique IP addresses

func (*AuditRepository) List

List returns paginated audit events with optional filters

func (*AuditRepository) Search added in v0.0.8

Search performs full-text search on audit events (implements audit.SearchRepository)

func (*AuditRepository) SearchPostgreSQL added in v0.0.8

func (r *AuditRepository) SearchPostgreSQL(ctx context.Context, query *audit.SearchQuery) (*audit.SearchResponse, error)

SearchPostgreSQL performs PostgreSQL tsvector full-text search

func (*AuditRepository) SearchSQLite added in v0.0.8

func (r *AuditRepository) SearchSQLite(ctx context.Context, query *audit.SearchQuery) (*audit.SearchResponse, error)

SearchSQLite performs SQLite FTS5 full-text search (placeholder for SQLite support)

type AuthorizationCodeRepository

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

AuthorizationCodeRepository handles authorization code persistence

func NewAuthorizationCodeRepository

func NewAuthorizationCodeRepository(db *bun.DB) *AuthorizationCodeRepository

NewAuthorizationCodeRepository creates a new authorization code repository

func (*AuthorizationCodeRepository) Create

Create stores a new authorization code

func (*AuthorizationCodeRepository) DeleteBySession

func (r *AuthorizationCodeRepository) DeleteBySession(ctx context.Context, sessionID xid.ID) error

DeleteBySession removes authorization codes associated with a session

func (*AuthorizationCodeRepository) DeleteExpired

func (r *AuthorizationCodeRepository) DeleteExpired(ctx context.Context) error

DeleteExpired removes expired authorization codes

func (*AuthorizationCodeRepository) FindByCode

FindByCode retrieves an authorization code by its code value

func (*AuthorizationCodeRepository) FindByCodeWithContext

func (r *AuthorizationCodeRepository) FindByCodeWithContext(ctx context.Context, code string, appID, envID xid.ID, orgID *xid.ID) (*schema.AuthorizationCode, error)

FindByCodeWithContext retrieves an authorization code with context filtering

func (*AuthorizationCodeRepository) FindBySession

func (r *AuthorizationCodeRepository) FindBySession(ctx context.Context, sessionID xid.ID) ([]*schema.AuthorizationCode, error)

FindBySession retrieves authorization codes for a specific session

func (*AuthorizationCodeRepository) FindByUserAndClient

func (r *AuthorizationCodeRepository) FindByUserAndClient(ctx context.Context, userID xid.ID, clientID string) ([]*schema.AuthorizationCode, error)

FindByUserAndClient retrieves authorization codes for a specific user and client

func (*AuthorizationCodeRepository) MarkAsUsed

func (r *AuthorizationCodeRepository) MarkAsUsed(ctx context.Context, code string) error

MarkAsUsed marks an authorization code as used

type DatabaseRetryStorage added in v0.0.7

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

DatabaseRetryStorage implements notification.RetryStorage using the database repository

func (*DatabaseRetryStorage) Delete added in v0.0.7

func (s *DatabaseRetryStorage) Delete(ctx context.Context, id xid.ID) error

Delete removes an item from the queue

func (*DatabaseRetryStorage) Dequeue added in v0.0.7

func (s *DatabaseRetryStorage) Dequeue(ctx context.Context, limit int) ([]*notification.RetryItem, error)

Dequeue retrieves items ready for retry

func (*DatabaseRetryStorage) Enqueue added in v0.0.7

Enqueue adds an item to the retry queue

func (*DatabaseRetryStorage) GetStats added in v0.0.7

GetStats returns queue statistics

func (*DatabaseRetryStorage) MarkFailed added in v0.0.7

func (s *DatabaseRetryStorage) MarkFailed(ctx context.Context, item *notification.RetryItem) error

MarkFailed marks an item as permanently failed

func (*DatabaseRetryStorage) Update added in v0.0.7

Update updates an item's retry state

type DeviceRepository

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

DeviceRepository implements core device repository using Bun

func NewDeviceRepository

func NewDeviceRepository(db *bun.DB) *DeviceRepository

NewDeviceRepository creates a new device repository

func (*DeviceRepository) CountDevices

func (r *DeviceRepository) CountDevices(ctx context.Context, userID xid.ID) (int, error)

CountDevices counts devices for a user

func (*DeviceRepository) CreateDevice

func (r *DeviceRepository) CreateDevice(ctx context.Context, d *schema.Device) error

CreateDevice creates a new device

func (*DeviceRepository) DeleteDevice

func (r *DeviceRepository) DeleteDevice(ctx context.Context, id xid.ID) error

DeleteDevice soft deletes a device by ID

func (*DeviceRepository) DeleteDeviceByFingerprint

func (r *DeviceRepository) DeleteDeviceByFingerprint(ctx context.Context, userID xid.ID, fingerprint string) error

DeleteDeviceByFingerprint soft deletes a device by user ID and fingerprint

func (*DeviceRepository) FindDeviceByFingerprint

func (r *DeviceRepository) FindDeviceByFingerprint(ctx context.Context, userID xid.ID, fingerprint string) (*schema.Device, error)

FindDeviceByFingerprint finds a device by user ID and fingerprint

func (*DeviceRepository) FindDeviceByID

func (r *DeviceRepository) FindDeviceByID(ctx context.Context, id xid.ID) (*schema.Device, error)

FindDeviceByID finds a device by ID

func (*DeviceRepository) ListDevices

ListDevices lists devices with filtering and pagination

func (*DeviceRepository) UpdateDevice

func (r *DeviceRepository) UpdateDevice(ctx context.Context, d *schema.Device) error

UpdateDevice updates a device

type EmailOTPRepository

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

EmailOTPRepository provides persistence for Email OTP entities

func NewEmailOTPRepository

func NewEmailOTPRepository(db *bun.DB) *EmailOTPRepository

func (*EmailOTPRepository) Consume

func (r *EmailOTPRepository) Consume(ctx context.Context, rec *schema.EmailOTP, now time.Time) error

Consume marks OTP as consumed by expiring now

func (*EmailOTPRepository) Create

func (r *EmailOTPRepository) Create(ctx context.Context, email, otp string, expiresAt time.Time) error

Create stores a new email OTP record

func (*EmailOTPRepository) FindByEmail

func (r *EmailOTPRepository) FindByEmail(ctx context.Context, email string, now time.Time) (*schema.EmailOTP, error)

FindByEmail returns the latest active OTP record for an email

func (*EmailOTPRepository) IncrementAttempts

func (r *EmailOTPRepository) IncrementAttempts(ctx context.Context, rec *schema.EmailOTP) error

IncrementAttempts increments attempts count

type FormSubmissionStats

type FormSubmissionStats struct {
	Total    int            `json:"total"`
	ByStatus map[string]int `json:"byStatus"`
}

FormSubmissionStats represents submission statistics for a form

type IdentityVerificationRepository

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

IdentityVerificationRepository implements the identity verification repository

func NewIdentityVerificationRepository

func NewIdentityVerificationRepository(db *bun.DB) *IdentityVerificationRepository

NewIdentityVerificationRepository creates a new identity verification repository

func (*IdentityVerificationRepository) CountVerificationsByUser

func (r *IdentityVerificationRepository) CountVerificationsByUser(ctx context.Context, appID xid.ID, userID xid.ID, since time.Time) (int, error)

CountVerificationsByUser counts verifications for a user since a given time with V2 context filtering

func (*IdentityVerificationRepository) CreateDocument

CreateDocument creates a new document record

func (*IdentityVerificationRepository) CreateSession

CreateSession creates a new session record

func (*IdentityVerificationRepository) CreateUserVerificationStatus

func (r *IdentityVerificationRepository) CreateUserVerificationStatus(ctx context.Context, status *schema.UserVerificationStatus) error

CreateUserVerificationStatus creates a new user verification status

func (*IdentityVerificationRepository) CreateVerification

func (r *IdentityVerificationRepository) CreateVerification(ctx context.Context, verification *schema.IdentityVerification) error

CreateVerification creates a new verification record

func (*IdentityVerificationRepository) DeleteDocument

func (r *IdentityVerificationRepository) DeleteDocument(ctx context.Context, appID xid.ID, id string) error

DeleteDocument soft deletes a document record with V2 context filtering

func (*IdentityVerificationRepository) DeleteSession

func (r *IdentityVerificationRepository) DeleteSession(ctx context.Context, appID xid.ID, id string) error

DeleteSession deletes a session record with V2 context filtering

func (*IdentityVerificationRepository) DeleteUserVerificationStatus

func (r *IdentityVerificationRepository) DeleteUserVerificationStatus(ctx context.Context, appID xid.ID, orgID xid.ID, userID xid.ID) error

DeleteUserVerificationStatus deletes a user verification status with V2 context filtering

func (*IdentityVerificationRepository) DeleteVerification

func (r *IdentityVerificationRepository) DeleteVerification(ctx context.Context, appID xid.ID, id string) error

DeleteVerification deletes a verification record with V2 context filtering

func (*IdentityVerificationRepository) GetBlockedUsers

func (r *IdentityVerificationRepository) GetBlockedUsers(ctx context.Context, appID xid.ID, limit, offset int) ([]*schema.UserVerificationStatus, error)

GetBlockedUsers retrieves blocked users with V2 context filtering

func (*IdentityVerificationRepository) GetDocumentByID

GetDocumentByID retrieves a document by ID with V2 context filtering

func (*IdentityVerificationRepository) GetDocumentsByVerificationID

func (r *IdentityVerificationRepository) GetDocumentsByVerificationID(ctx context.Context, appID xid.ID, verificationID string) ([]*schema.IdentityVerificationDocument, error)

GetDocumentsByVerificationID retrieves all documents for a verification with V2 context filtering

func (*IdentityVerificationRepository) GetDocumentsForDeletion

func (r *IdentityVerificationRepository) GetDocumentsForDeletion(ctx context.Context, appID xid.ID, before time.Time, limit int) ([]*schema.IdentityVerificationDocument, error)

GetDocumentsForDeletion retrieves documents that should be deleted with V2 context filtering

func (*IdentityVerificationRepository) GetExpiredSessions

func (r *IdentityVerificationRepository) GetExpiredSessions(ctx context.Context, appID xid.ID, before time.Time, limit int) ([]*schema.IdentityVerificationSession, error)

GetExpiredSessions retrieves expired sessions with V2 context filtering

func (*IdentityVerificationRepository) GetExpiredVerifications

func (r *IdentityVerificationRepository) GetExpiredVerifications(ctx context.Context, appID xid.ID, before time.Time, limit int) ([]*schema.IdentityVerification, error)

GetExpiredVerifications retrieves expired verifications with V2 context filtering

func (*IdentityVerificationRepository) GetLatestVerificationByUser

func (r *IdentityVerificationRepository) GetLatestVerificationByUser(ctx context.Context, appID xid.ID, userID xid.ID) (*schema.IdentityVerification, error)

GetLatestVerificationByUser retrieves the most recent verification for a user with V2 context filtering

func (*IdentityVerificationRepository) GetProviderStats

func (r *IdentityVerificationRepository) GetProviderStats(ctx context.Context, appID xid.ID, provider string, from, to time.Time) (map[string]interface{}, error)

GetProviderStats retrieves provider-specific statistics with V2 context filtering

func (*IdentityVerificationRepository) GetSessionByID

GetSessionByID retrieves a session by ID with V2 context filtering

func (*IdentityVerificationRepository) GetSessionsByUserID

func (r *IdentityVerificationRepository) GetSessionsByUserID(ctx context.Context, appID xid.ID, userID xid.ID, limit, offset int) ([]*schema.IdentityVerificationSession, error)

GetSessionsByUserID retrieves all sessions for a user with V2 context filtering

func (*IdentityVerificationRepository) GetUserVerificationStatus

func (r *IdentityVerificationRepository) GetUserVerificationStatus(ctx context.Context, appID xid.ID, orgID xid.ID, userID xid.ID) (*schema.UserVerificationStatus, error)

GetUserVerificationStatus retrieves the verification status for a user with V2 context filtering

func (*IdentityVerificationRepository) GetUsersByVerificationLevel

func (r *IdentityVerificationRepository) GetUsersByVerificationLevel(ctx context.Context, appID xid.ID, level string, limit, offset int) ([]*schema.UserVerificationStatus, error)

GetUsersByVerificationLevel retrieves users by verification level with V2 context filtering

func (*IdentityVerificationRepository) GetUsersRequiringReverification

func (r *IdentityVerificationRepository) GetUsersRequiringReverification(ctx context.Context, appID xid.ID, limit int) ([]*schema.UserVerificationStatus, error)

GetUsersRequiringReverification retrieves users requiring re-verification with V2 context filtering

func (*IdentityVerificationRepository) GetVerificationByID

func (r *IdentityVerificationRepository) GetVerificationByID(ctx context.Context, appID xid.ID, id string) (*schema.IdentityVerification, error)

GetVerificationByID retrieves a verification by ID with V2 context filtering

func (*IdentityVerificationRepository) GetVerificationByProviderCheckID

func (r *IdentityVerificationRepository) GetVerificationByProviderCheckID(ctx context.Context, appID xid.ID, providerCheckID string) (*schema.IdentityVerification, error)

GetVerificationByProviderCheckID retrieves a verification by provider check ID with V2 context filtering

func (*IdentityVerificationRepository) GetVerificationStats

func (r *IdentityVerificationRepository) GetVerificationStats(ctx context.Context, appID xid.ID, orgID xid.ID, from, to time.Time) (map[string]interface{}, error)

GetVerificationStats retrieves verification statistics with V2 context filtering

func (*IdentityVerificationRepository) GetVerificationsByOrgID

func (r *IdentityVerificationRepository) GetVerificationsByOrgID(ctx context.Context, appID xid.ID, orgID xid.ID, limit, offset int) ([]*schema.IdentityVerification, error)

GetVerificationsByOrgID retrieves all verifications for an organization with V2 context filtering

func (*IdentityVerificationRepository) GetVerificationsByStatus

func (r *IdentityVerificationRepository) GetVerificationsByStatus(ctx context.Context, appID xid.ID, status string, limit, offset int) ([]*schema.IdentityVerification, error)

GetVerificationsByStatus retrieves verifications by status with V2 context filtering

func (*IdentityVerificationRepository) GetVerificationsByType

func (r *IdentityVerificationRepository) GetVerificationsByType(ctx context.Context, appID xid.ID, verificationType string, limit, offset int) ([]*schema.IdentityVerification, error)

GetVerificationsByType retrieves verifications by type with V2 context filtering

func (*IdentityVerificationRepository) GetVerificationsByUserID

func (r *IdentityVerificationRepository) GetVerificationsByUserID(ctx context.Context, appID xid.ID, userID xid.ID, limit, offset int) ([]*schema.IdentityVerification, error)

GetVerificationsByUserID retrieves all verifications for a user with V2 context filtering

func (*IdentityVerificationRepository) UpdateDocument

UpdateDocument updates a document record

func (*IdentityVerificationRepository) UpdateSession

UpdateSession updates a session record

func (*IdentityVerificationRepository) UpdateUserVerificationStatus

func (r *IdentityVerificationRepository) UpdateUserVerificationStatus(ctx context.Context, status *schema.UserVerificationStatus) error

UpdateUserVerificationStatus updates a user verification status

func (*IdentityVerificationRepository) UpdateVerification

func (r *IdentityVerificationRepository) UpdateVerification(ctx context.Context, verification *schema.IdentityVerification) error

UpdateVerification updates a verification record

type ImpersonationRepository

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

ImpersonationRepository implements the impersonation repository using Bun Updated for V2 architecture: App → Environment → Organization

func NewImpersonationRepository

func NewImpersonationRepository(db *bun.DB) *ImpersonationRepository

NewImpersonationRepository creates a new impersonation repository

func (*ImpersonationRepository) Create

Create creates a new impersonation session

func (*ImpersonationRepository) CreateAuditEvent

CreateAuditEvent creates an audit event

func (*ImpersonationRepository) ExpireOldSessions

func (r *ImpersonationRepository) ExpireOldSessions(ctx context.Context) (int, error)

ExpireOldSessions expires sessions that have passed their expiry time

func (*ImpersonationRepository) Get

Get retrieves an impersonation session by ID and app (column organization_id contains appID)

func (*ImpersonationRepository) GetActive

func (r *ImpersonationRepository) GetActive(ctx context.Context, impersonatorID xid.ID, appID xid.ID) (*schema.ImpersonationSession, error)

GetActive retrieves the active impersonation session for an impersonator Note: appID maps to column organization_id (V2 architecture)

func (*ImpersonationRepository) GetBySessionID

func (r *ImpersonationRepository) GetBySessionID(ctx context.Context, sessionID xid.ID) (*schema.ImpersonationSession, error)

GetBySessionID retrieves an impersonation session by the session ID

func (*ImpersonationRepository) ListAuditEvents

ListAuditEvents retrieves audit events with pagination and filtering Note: filter.AppID maps to column organization_id (V2 architecture)

func (*ImpersonationRepository) ListSessions

ListSessions retrieves impersonation sessions with pagination and filtering Note: filter.AppID maps to column organization_id (V2 architecture)

func (*ImpersonationRepository) Update

Update updates an impersonation session

type InvitationRepository

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

InvitationRepository handles invitation data access using schema models

func NewInvitationRepository

func NewInvitationRepository(db *bun.DB) *InvitationRepository

NewInvitationRepository creates a new invitation repository

func (*InvitationRepository) Create

func (r *InvitationRepository) Create(ctx context.Context, invitation *schema.Invitation) error

Create creates a new invitation

func (*InvitationRepository) Delete

func (r *InvitationRepository) Delete(ctx context.Context, id xid.ID) error

Delete deletes an invitation

func (*InvitationRepository) DeleteExpired

func (r *InvitationRepository) DeleteExpired(ctx context.Context) error

DeleteExpired deletes expired invitations

func (*InvitationRepository) FindByID

func (r *InvitationRepository) FindByID(ctx context.Context, id xid.ID) (*schema.Invitation, error)

FindByID finds an invitation by ID

func (*InvitationRepository) FindByToken

func (r *InvitationRepository) FindByToken(ctx context.Context, token string) (*schema.Invitation, error)

FindByToken finds an invitation by token

func (*InvitationRepository) ListByApp

func (r *InvitationRepository) ListByApp(ctx context.Context, appID xid.ID, limit, offset int) ([]*schema.Invitation, error)

ListByApp lists invitations by app with pagination

func (*InvitationRepository) Update

func (r *InvitationRepository) Update(ctx context.Context, invitation *schema.Invitation) error

Update updates an invitation

type JWTKeyRepository

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

JWTKeyRepository handles JWT key database operations

func NewJWTKeyRepository

func NewJWTKeyRepository(db *bun.DB) *JWTKeyRepository

NewJWTKeyRepository creates a new JWT key repository

func (*JWTKeyRepository) CleanupExpiredJWTKeys

func (r *JWTKeyRepository) CleanupExpiredJWTKeys(ctx context.Context) (int64, error)

CleanupExpiredJWTKeys removes expired JWT keys

func (*JWTKeyRepository) CountJWTKeys

func (r *JWTKeyRepository) CountJWTKeys(ctx context.Context, appID xid.ID) (int, error)

CountJWTKeys counts JWT keys for an app

func (*JWTKeyRepository) CreateJWTKey

func (r *JWTKeyRepository) CreateJWTKey(ctx context.Context, key *schema.JWTKey) error

CreateJWTKey creates a new JWT key

func (*JWTKeyRepository) DeactivateJWTKey

func (r *JWTKeyRepository) DeactivateJWTKey(ctx context.Context, id xid.ID) error

DeactivateJWTKey deactivates a JWT key

func (*JWTKeyRepository) DeleteJWTKey

func (r *JWTKeyRepository) DeleteJWTKey(ctx context.Context, id xid.ID) error

DeleteJWTKey soft deletes a JWT key

func (*JWTKeyRepository) FindJWTKeyByID

func (r *JWTKeyRepository) FindJWTKeyByID(ctx context.Context, id xid.ID) (*schema.JWTKey, error)

FindJWTKeyByID finds a JWT key by ID

func (*JWTKeyRepository) FindJWTKeyByKeyID

func (r *JWTKeyRepository) FindJWTKeyByKeyID(ctx context.Context, keyID string, appID xid.ID) (*schema.JWTKey, error)

FindJWTKeyByKeyID finds a JWT key by key ID and app ID

func (*JWTKeyRepository) FindPlatformJWTKeyByKeyID

func (r *JWTKeyRepository) FindPlatformJWTKeyByKeyID(ctx context.Context, keyID string) (*schema.JWTKey, error)

FindPlatformJWTKeyByKeyID finds a platform JWT key by key ID

func (*JWTKeyRepository) ListJWTKeys

ListJWTKeys lists JWT keys with pagination and filtering

func (*JWTKeyRepository) ListPlatformJWTKeys

func (r *JWTKeyRepository) ListPlatformJWTKeys(ctx context.Context, filter *jwt.ListJWTKeysFilter) (*pagination.PageResponse[*schema.JWTKey], error)

ListPlatformJWTKeys lists platform JWT keys with pagination

func (*JWTKeyRepository) UpdateJWTKey

func (r *JWTKeyRepository) UpdateJWTKey(ctx context.Context, key *schema.JWTKey) error

UpdateJWTKey updates a JWT key

func (*JWTKeyRepository) UpdateJWTKeyUsage

func (r *JWTKeyRepository) UpdateJWTKeyUsage(ctx context.Context, keyID string) error

UpdateJWTKeyUsage updates the usage statistics for a JWT key

type MFARepository

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

MFARepository provides persistence for MFA entities

func NewMFARepository

func NewMFARepository(db *bun.DB) *MFARepository

NewMFARepository creates a new MFA repository

func (*MFARepository) CleanupExpiredChallenges

func (r *MFARepository) CleanupExpiredChallenges(ctx context.Context) (int, error)

CleanupExpiredChallenges removes expired challenges

func (*MFARepository) CleanupExpiredDevices

func (r *MFARepository) CleanupExpiredDevices(ctx context.Context) (int, error)

CleanupExpiredDevices removes expired trusted devices

func (*MFARepository) CleanupExpiredSessions

func (r *MFARepository) CleanupExpiredSessions(ctx context.Context) (int, error)

CleanupExpiredSessions removes expired sessions

func (*MFARepository) CleanupOldAttempts

func (r *MFARepository) CleanupOldAttempts(ctx context.Context, olderThan time.Time) (int, error)

CleanupOldAttempts removes old attempt records

func (*MFARepository) CompleteSession

func (r *MFARepository) CompleteSession(ctx context.Context, sessionID xid.ID) error

CompleteSession marks a session as completed

func (*MFARepository) CountFailedAttempts

func (r *MFARepository) CountFailedAttempts(ctx context.Context, userID xid.ID, since time.Time) (int, error)

CountFailedAttempts counts failed attempts within a time window

func (*MFARepository) CreateAttempt

func (r *MFARepository) CreateAttempt(ctx context.Context, attempt *schema.MFAAttempt) error

CreateAttempt creates a new MFA attempt record

func (*MFARepository) CreateBypass

func (r *MFARepository) CreateBypass(ctx context.Context, bypass *schema.MFABypass) error

CreateBypass creates a new MFA bypass

func (*MFARepository) CreateChallenge

func (r *MFARepository) CreateChallenge(ctx context.Context, challenge *schema.MFAChallenge) error

CreateChallenge creates a new MFA challenge

func (*MFARepository) CreateFactor

func (r *MFARepository) CreateFactor(ctx context.Context, factor *schema.MFAFactor) error

CreateFactor creates a new MFA factor

func (*MFARepository) CreateRiskAssessment

func (r *MFARepository) CreateRiskAssessment(ctx context.Context, assessment *schema.MFARiskAssessment) error

CreateRiskAssessment creates a new risk assessment

func (*MFARepository) CreateSession

func (r *MFARepository) CreateSession(ctx context.Context, session *schema.MFASession) error

CreateSession creates a new MFA session

func (*MFARepository) CreateTrustedDevice

func (r *MFARepository) CreateTrustedDevice(ctx context.Context, device *schema.MFATrustedDevice) error

CreateTrustedDevice creates a new trusted device

func (*MFARepository) DB

func (r *MFARepository) DB() *bun.DB

DB returns the underlying database connection

func (*MFARepository) DeleteFactor

func (r *MFARepository) DeleteFactor(ctx context.Context, factorID xid.ID) error

DeleteFactor deletes a factor

func (*MFARepository) DeleteTrustedDevice

func (r *MFARepository) DeleteTrustedDevice(ctx context.Context, deviceID xid.ID) error

DeleteTrustedDevice deletes a trusted device

func (*MFARepository) GetActiveBypass

func (r *MFARepository) GetActiveBypass(ctx context.Context, appID, userID xid.ID) (*schema.MFABypass, error)

GetActiveBypass retrieves an active bypass for a user

func (*MFARepository) GetChallenge

func (r *MFARepository) GetChallenge(ctx context.Context, challengeID xid.ID) (*schema.MFAChallenge, error)

GetChallenge retrieves a challenge by ID

func (*MFARepository) GetFactor

func (r *MFARepository) GetFactor(ctx context.Context, factorID xid.ID) (*schema.MFAFactor, error)

GetFactor retrieves a factor by ID

func (*MFARepository) GetLatestRiskAssessment

func (r *MFARepository) GetLatestRiskAssessment(ctx context.Context, userID xid.ID) (*schema.MFARiskAssessment, error)

GetLatestRiskAssessment retrieves the most recent risk assessment for a user

func (*MFARepository) GetPolicy

func (r *MFARepository) GetPolicy(ctx context.Context, appID xid.ID, orgID *xid.ID) (*schema.MFAPolicy, error)

GetPolicy retrieves the MFA policy for an app/organization

func (*MFARepository) GetRecentAttempts

func (r *MFARepository) GetRecentAttempts(ctx context.Context, userID xid.ID, since time.Time) ([]*schema.MFAAttempt, error)

GetRecentAttempts retrieves recent attempts for rate limiting

func (*MFARepository) GetRiskAssessmentBySession

func (r *MFARepository) GetRiskAssessmentBySession(ctx context.Context, sessionID xid.ID) (*schema.MFARiskAssessment, error)

GetRiskAssessmentBySession retrieves risk assessment for a session

func (*MFARepository) GetSession

func (r *MFARepository) GetSession(ctx context.Context, sessionID xid.ID) (*schema.MFASession, error)

GetSession retrieves a session by ID

func (*MFARepository) GetSessionByToken

func (r *MFARepository) GetSessionByToken(ctx context.Context, token string) (*schema.MFASession, error)

GetSessionByToken retrieves a session by token

func (*MFARepository) GetTrustedDevice

func (r *MFARepository) GetTrustedDevice(ctx context.Context, userID xid.ID, deviceID string) (*schema.MFATrustedDevice, error)

GetTrustedDevice retrieves a trusted device

func (*MFARepository) IncrementChallengeAttempts

func (r *MFARepository) IncrementChallengeAttempts(ctx context.Context, challengeID xid.ID) error

IncrementChallengeAttempts increments the attempt counter

func (*MFARepository) ListTrustedDevices

func (r *MFARepository) ListTrustedDevices(ctx context.Context, userID xid.ID) ([]*schema.MFATrustedDevice, error)

ListTrustedDevices retrieves all trusted devices for a user

func (*MFARepository) ListUserFactors

func (r *MFARepository) ListUserFactors(ctx context.Context, userID xid.ID, statusFilter ...string) ([]*schema.MFAFactor, error)

ListUserFactors retrieves all factors for a user

func (*MFARepository) RevokeBypass

func (r *MFARepository) RevokeBypass(ctx context.Context, bypassID, revokedBy xid.ID) error

RevokeBypass revokes an MFA bypass

func (*MFARepository) UpdateChallenge

func (r *MFARepository) UpdateChallenge(ctx context.Context, challenge *schema.MFAChallenge) error

UpdateChallenge updates a challenge

func (*MFARepository) UpdateDeviceLastUsed

func (r *MFARepository) UpdateDeviceLastUsed(ctx context.Context, deviceID xid.ID) error

UpdateDeviceLastUsed updates the last used timestamp

func (*MFARepository) UpdateFactor

func (r *MFARepository) UpdateFactor(ctx context.Context, factor *schema.MFAFactor) error

UpdateFactor updates a factor

func (*MFARepository) UpdateFactorLastUsed

func (r *MFARepository) UpdateFactorLastUsed(ctx context.Context, factorID xid.ID) error

UpdateFactorLastUsed updates the last used timestamp

func (*MFARepository) UpdateSession

func (r *MFARepository) UpdateSession(ctx context.Context, session *schema.MFASession) error

UpdateSession updates a session

func (*MFARepository) UpdateTrustedDevice

func (r *MFARepository) UpdateTrustedDevice(ctx context.Context, device *schema.MFATrustedDevice) error

UpdateTrustedDevice updates a trusted device

func (*MFARepository) UpsertPolicy

func (r *MFARepository) UpsertPolicy(ctx context.Context, policy *schema.MFAPolicy) error

UpsertPolicy creates or updates an MFA policy

type MagicLinkRepository

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

MagicLinkRepository provides persistence for Magic Links

func NewMagicLinkRepository

func NewMagicLinkRepository(db *bun.DB) *MagicLinkRepository

func (*MagicLinkRepository) Consume

func (r *MagicLinkRepository) Consume(ctx context.Context, rec *schema.MagicLink, now time.Time) error

Consume marks link as expired by setting expiresAt to now

func (*MagicLinkRepository) Create

func (r *MagicLinkRepository) Create(ctx context.Context, email, token string, appID xid.ID, userOrganizationID *xid.ID, expiresAt time.Time) error

Create stores a new magic link record with app and optional org scoping

func (*MagicLinkRepository) FindByToken

func (r *MagicLinkRepository) FindByToken(ctx context.Context, token string, appID xid.ID, userOrganizationID *xid.ID, now time.Time) (*schema.MagicLink, error)

FindByToken returns an active magic link by token, scoped to app and optional org

type MemberRepository

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

MemberRepository handles member data access using schema models

func NewMemberRepository

func NewMemberRepository(db *bun.DB) *MemberRepository

NewMemberRepository creates a new member repository

func (*MemberRepository) CountByApp

func (r *MemberRepository) CountByApp(ctx context.Context, appID xid.ID) (int, error)

CountByApp returns the total number of members in an app

func (*MemberRepository) Create

func (r *MemberRepository) Create(ctx context.Context, member *schema.Member) error

Create creates a new member

func (*MemberRepository) Delete

func (r *MemberRepository) Delete(ctx context.Context, id xid.ID) error

Delete deletes a member

func (*MemberRepository) DeleteByUserID

func (r *MemberRepository) DeleteByUserID(ctx context.Context, userID xid.ID) error

DeleteByUserID deletes all memberships for a user

func (*MemberRepository) FindByID

func (r *MemberRepository) FindByID(ctx context.Context, id xid.ID) (*schema.Member, error)

FindByID finds a member by ID

func (*MemberRepository) FindByUserAndApp

func (r *MemberRepository) FindByUserAndApp(ctx context.Context, userID, appID xid.ID) (*schema.Member, error)

FindByUserAndApp finds a member by user and app ID

func (*MemberRepository) ListByApp

func (r *MemberRepository) ListByApp(ctx context.Context, appID xid.ID, role *schema.MemberRole, status *schema.MemberStatus, limit, offset int) ([]*schema.Member, int64, error)

ListByApp lists members by app with pagination and optional filters

func (*MemberRepository) ListByUser

func (r *MemberRepository) ListByUser(ctx context.Context, userID xid.ID) ([]*schema.Member, error)

ListByUser lists apps a user is a member of

func (*MemberRepository) Update

func (r *MemberRepository) Update(ctx context.Context, member *schema.Member) error

Update updates a member

type NotificationQueueRepository added in v0.0.7

type NotificationQueueRepository interface {
	// Enqueue adds an item to the retry queue
	Enqueue(ctx context.Context, item *schema.NotificationQueue) error
	// Dequeue retrieves items ready for retry
	Dequeue(ctx context.Context, limit int) ([]*schema.NotificationQueue, error)
	// Update updates an item's retry state
	Update(ctx context.Context, item *schema.NotificationQueue) error
	// Delete removes an item from the queue
	Delete(ctx context.Context, id xid.ID) error
	// MarkFailed marks an item as permanently failed
	MarkFailed(ctx context.Context, id xid.ID, lastError string) error
	// MarkSucceeded marks an item as succeeded
	MarkSucceeded(ctx context.Context, id xid.ID) error
	// GetStats returns queue statistics
	GetStats(ctx context.Context) (*schema.NotificationQueueStats, error)
	// GetByID retrieves a queue item by ID
	GetByID(ctx context.Context, id xid.ID) (*schema.NotificationQueue, error)
	// CleanupOld removes old completed/failed items
	CleanupOld(ctx context.Context, olderThan time.Time) error
}

NotificationQueueRepository defines the interface for notification queue operations

func NewNotificationQueueRepository added in v0.0.7

func NewNotificationQueueRepository(db *bun.DB) NotificationQueueRepository

NewNotificationQueueRepository creates a new notification queue repository

type OAuthClientRepository

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

OAuthClientRepository provides persistence for OAuth client registrations

func NewOAuthClientRepository

func NewOAuthClientRepository(db *bun.DB) *OAuthClientRepository

func (*OAuthClientRepository) Create

Create inserts a new OAuthClient record

func (*OAuthClientRepository) Delete

func (r *OAuthClientRepository) Delete(ctx context.Context, id xid.ID) error

Delete removes an OAuth client

func (*OAuthClientRepository) ExistsByClientID

func (r *OAuthClientRepository) ExistsByClientID(ctx context.Context, clientID string) (bool, error)

ExistsByClientID checks if a client with the given client_id exists

func (*OAuthClientRepository) FindByClientID

func (r *OAuthClientRepository) FindByClientID(ctx context.Context, clientID string) (*schema.OAuthClient, error)

FindByClientID returns an OAuthClient by client_id (no context filtering)

func (*OAuthClientRepository) FindByClientIDWithContext

func (r *OAuthClientRepository) FindByClientIDWithContext(ctx context.Context, appID, envID xid.ID, orgID *xid.ID, clientID string) (*schema.OAuthClient, error)

FindByClientIDWithContext returns an OAuthClient with org hierarchy support Tries org-specific client first, then falls back to app-level

func (*OAuthClientRepository) FindByID

FindByID returns an OAuthClient by ID

func (*OAuthClientRepository) ListByApp

func (r *OAuthClientRepository) ListByApp(ctx context.Context, appID, envID xid.ID, limit, offset int) ([]*schema.OAuthClient, int, error)

ListByApp returns all clients for an app and environment

func (*OAuthClientRepository) ListByOrg

func (r *OAuthClientRepository) ListByOrg(ctx context.Context, appID, envID, orgID xid.ID, limit, offset int) ([]*schema.OAuthClient, int, error)

ListByOrg returns all org-specific clients

func (*OAuthClientRepository) Update

Update updates an existing OAuth client

type OAuthConsentRepository

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

OAuthConsentRepository handles OAuth consent persistence

func NewOAuthConsentRepository

func NewOAuthConsentRepository(db *bun.DB) *OAuthConsentRepository

NewOAuthConsentRepository creates a new OAuth consent repository

func (*OAuthConsentRepository) Create

Create stores a new consent decision

func (*OAuthConsentRepository) Delete

func (r *OAuthConsentRepository) Delete(ctx context.Context, id xid.ID) error

Delete removes a consent

func (*OAuthConsentRepository) DeleteByUserAndClient

func (r *OAuthConsentRepository) DeleteByUserAndClient(ctx context.Context, userID xid.ID, clientID string) error

DeleteByUserAndClient removes consent for a specific user and client

func (*OAuthConsentRepository) DeleteExpired

func (r *OAuthConsentRepository) DeleteExpired(ctx context.Context) error

DeleteExpired removes expired consents

func (*OAuthConsentRepository) FindByUserAndClient

func (r *OAuthConsentRepository) FindByUserAndClient(ctx context.Context, userID xid.ID, clientID string, appID, envID xid.ID, orgID *xid.ID) (*schema.OAuthConsent, error)

FindByUserAndClient retrieves consent for a user and client

func (*OAuthConsentRepository) HasValidConsent

func (r *OAuthConsentRepository) HasValidConsent(ctx context.Context, userID xid.ID, clientID string, requiredScopes []string, appID, envID xid.ID, orgID *xid.ID) (bool, error)

HasValidConsent checks if user has valid consent for client with required scopes

func (*OAuthConsentRepository) ListByUser

func (r *OAuthConsentRepository) ListByUser(ctx context.Context, userID xid.ID, appID, envID xid.ID, orgID *xid.ID) ([]*schema.OAuthConsent, error)

ListByUser retrieves all consents for a user

func (*OAuthConsentRepository) Update

Update updates an existing consent

type OAuthTokenRepository

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

OAuthTokenRepository handles OAuth token persistence

func NewOAuthTokenRepository

func NewOAuthTokenRepository(db *bun.DB) *OAuthTokenRepository

NewOAuthTokenRepository creates a new OAuth token repository

func (*OAuthTokenRepository) Create

func (r *OAuthTokenRepository) Create(ctx context.Context, token *schema.OAuthToken) error

Create stores a new OAuth token

func (*OAuthTokenRepository) DeleteExpired

func (r *OAuthTokenRepository) DeleteExpired(ctx context.Context) error

DeleteExpired removes expired tokens

func (*OAuthTokenRepository) FindByAccessToken

func (r *OAuthTokenRepository) FindByAccessToken(ctx context.Context, accessToken string) (*schema.OAuthToken, error)

FindByAccessToken retrieves a token by its access token value

func (*OAuthTokenRepository) FindByJTI

func (r *OAuthTokenRepository) FindByJTI(ctx context.Context, jti string) (*schema.OAuthToken, error)

FindByJTI retrieves a token by its JWT ID

func (*OAuthTokenRepository) FindByRefreshToken

func (r *OAuthTokenRepository) FindByRefreshToken(ctx context.Context, refreshToken string) (*schema.OAuthToken, error)

FindByRefreshToken retrieves a token by its refresh token value

func (*OAuthTokenRepository) FindByUserAndClient

func (r *OAuthTokenRepository) FindByUserAndClient(ctx context.Context, userID xid.ID, clientID string) ([]*schema.OAuthToken, error)

FindByUserAndClient retrieves tokens for a specific user and client

func (*OAuthTokenRepository) FindByUserInOrg

func (r *OAuthTokenRepository) FindByUserInOrg(ctx context.Context, userID xid.ID, appID, envID xid.ID, orgID *xid.ID) ([]*schema.OAuthToken, error)

FindByUserInOrg retrieves all active tokens for a user in an organization

func (*OAuthTokenRepository) RevokeAllForClient

func (r *OAuthTokenRepository) RevokeAllForClient(ctx context.Context, clientID string) error

RevokeAllForClient revokes all tokens for a client

func (*OAuthTokenRepository) RevokeAllForUser

func (r *OAuthTokenRepository) RevokeAllForUser(ctx context.Context, userID xid.ID, appID, envID xid.ID, orgID *xid.ID) error

RevokeAllForUser revokes all tokens for a user in an org

func (*OAuthTokenRepository) RevokeByJTI

func (r *OAuthTokenRepository) RevokeByJTI(ctx context.Context, jti string) error

RevokeByJTI marks a token as revoked by JWT ID

func (*OAuthTokenRepository) RevokeByRefreshToken

func (r *OAuthTokenRepository) RevokeByRefreshToken(ctx context.Context, refreshToken string) error

RevokeByRefreshToken marks a token as revoked by refresh token

func (*OAuthTokenRepository) RevokeBySession

func (r *OAuthTokenRepository) RevokeBySession(ctx context.Context, sessionID xid.ID) error

RevokeBySession revokes all tokens associated with a session (cascade revocation)

func (*OAuthTokenRepository) RevokeToken

func (r *OAuthTokenRepository) RevokeToken(ctx context.Context, accessToken string) error

RevokeToken marks a token as revoked

func (*OAuthTokenRepository) Update

func (r *OAuthTokenRepository) Update(ctx context.Context, token *schema.OAuthToken) error

Update updates an existing OAuth token

func (*OAuthTokenRepository) UpdateRefreshToken

func (r *OAuthTokenRepository) UpdateRefreshToken(ctx context.Context, accessToken, newRefreshToken string, refreshExpiresAt *time.Time) error

UpdateRefreshToken updates the refresh token for an existing token

type PermissionRepository

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

PermissionRepository provides basic CRUD for permissions

func NewPermissionRepository

func NewPermissionRepository(db *bun.DB) *PermissionRepository

func (*PermissionRepository) Create

func (*PermissionRepository) CreateCustomPermission

func (r *PermissionRepository) CreateCustomPermission(ctx context.Context, name, description, category string, orgID xid.ID) (*schema.Permission, error)

func (*PermissionRepository) Delete

func (r *PermissionRepository) Delete(ctx context.Context, permissionID xid.ID) error

func (*PermissionRepository) FindByID

func (r *PermissionRepository) FindByID(ctx context.Context, permissionID xid.ID) (*schema.Permission, error)

func (*PermissionRepository) FindByName

func (r *PermissionRepository) FindByName(ctx context.Context, name string, appID xid.ID, orgID *xid.ID) (*schema.Permission, error)

func (*PermissionRepository) ListByApp

func (r *PermissionRepository) ListByApp(ctx context.Context, appID xid.ID) ([]*schema.Permission, error)

func (*PermissionRepository) ListByCategory

func (r *PermissionRepository) ListByCategory(ctx context.Context, category string, appID xid.ID) ([]*schema.Permission, error)

func (*PermissionRepository) ListByOrg

func (r *PermissionRepository) ListByOrg(ctx context.Context, orgID xid.ID) ([]*schema.Permission, error)

func (*PermissionRepository) Update

type PhoneRepository

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

PhoneRepository provides persistence for phone verification codes

func NewPhoneRepository

func NewPhoneRepository(db *bun.DB) *PhoneRepository

func (*PhoneRepository) Consume

Consume marks code as consumed by expiring now

func (*PhoneRepository) Create

func (r *PhoneRepository) Create(ctx context.Context, phone, code string, appID xid.ID, userOrganizationID *xid.ID, expiresAt time.Time) error

Create stores a new phone verification record with app and optional org scoping

func (*PhoneRepository) FindByPhone

func (r *PhoneRepository) FindByPhone(ctx context.Context, phone string, appID xid.ID, userOrganizationID *xid.ID, now time.Time) (*schema.PhoneVerification, error)

FindByPhone returns the latest active verification for a phone, scoped to app and optional org

func (*PhoneRepository) IncrementAttempts

func (r *PhoneRepository) IncrementAttempts(ctx context.Context, rec *schema.PhoneVerification) error

IncrementAttempts increments attempts count

type PolicyRepository

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

PolicyRepository implements rbac.PolicyRepository using Bun

func NewPolicyRepository

func NewPolicyRepository(db *bun.DB) *PolicyRepository

func (*PolicyRepository) Create

func (r *PolicyRepository) Create(ctx context.Context, expression string) error

func (*PolicyRepository) Delete

func (r *PolicyRepository) Delete(ctx context.Context, id xid.ID) error

Delete removes a policy by ID

func (*PolicyRepository) List

func (r *PolicyRepository) List(ctx context.Context) ([]schema.Policy, error)

List returns full policy rows for management

func (*PolicyRepository) ListAll

func (r *PolicyRepository) ListAll(ctx context.Context) ([]string, error)

func (*PolicyRepository) Update

func (r *PolicyRepository) Update(ctx context.Context, id xid.ID, expression string) error

Update modifies an existing policy's expression by ID

type Repo

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

func (*Repo) APIKey

func (r *Repo) APIKey() *APIKeyRepository

Authentication & Security

func (*Repo) App

func (r *Repo) App() *AppRepository

App & Environment

func (*Repo) Audit

func (r *Repo) Audit() *AuditRepository

func (*Repo) AuthorizationCode

func (r *Repo) AuthorizationCode() *AuthorizationCodeRepository

func (*Repo) Device

func (r *Repo) Device() *DeviceRepository

func (*Repo) EmailOTP

func (r *Repo) EmailOTP() *EmailOTPRepository

func (*Repo) Environment

func (r *Repo) Environment() environment.Repository

func (*Repo) Forms

func (r *Repo) Forms() forms.Repository

Forms & Webhooks

func (*Repo) IdentityVerification

func (r *Repo) IdentityVerification() *IdentityVerificationRepository

Identity & Verification

func (*Repo) Impersonation

func (r *Repo) Impersonation() *ImpersonationRepository

Impersonation

func (*Repo) JWTKey

func (r *Repo) JWTKey() *JWTKeyRepository

func (*Repo) MFA

func (r *Repo) MFA() *MFARepository
func (r *Repo) MagicLink() *MagicLinkRepository

func (*Repo) Notification

func (r *Repo) Notification() notification.Repository

func (*Repo) OAuthClient

func (r *Repo) OAuthClient() *OAuthClientRepository

func (*Repo) OAuthToken

func (r *Repo) OAuthToken() *OAuthTokenRepository

OAuth & SSO

func (*Repo) Organization

func (r *Repo) Organization() organization.OrganizationRepository

Organization repositories

func (*Repo) OrganizationInvitation

func (r *Repo) OrganizationInvitation() organization.InvitationRepository

func (*Repo) OrganizationMember

func (r *Repo) OrganizationMember() organization.MemberRepository

func (*Repo) OrganizationTeam

func (r *Repo) OrganizationTeam() organization.TeamRepository

func (*Repo) Permission

func (r *Repo) Permission() *PermissionRepository

func (*Repo) Phone

func (r *Repo) Phone() *PhoneRepository

Authentication Methods

func (*Repo) Policy

func (r *Repo) Policy() *PolicyRepository

func (*Repo) Role

func (r *Repo) Role() *RoleRepository

func (*Repo) RolePermission added in v0.0.3

func (r *Repo) RolePermission() *RolePermissionRepository

func (*Repo) SSOProvider

func (r *Repo) SSOProvider() *SSOProviderRepository

func (*Repo) Security

func (r *Repo) Security() *SecurityRepository

func (*Repo) Session

func (r *Repo) Session() *SessionRepository

func (*Repo) SocialAccount

func (r *Repo) SocialAccount() SocialAccountRepository

func (*Repo) SocialProviderConfig added in v0.0.3

func (r *Repo) SocialProviderConfig() SocialProviderConfigRepository

func (*Repo) TwoFA

func (r *Repo) TwoFA() *TwoFARepository

Multi-factor Authentication

func (*Repo) User

func (r *Repo) User() *UserRepository

Core repositories

func (*Repo) UserBan

func (r *Repo) UserBan() *UserBanRepository

func (*Repo) UserRole

func (r *Repo) UserRole() *UserRoleRepository

func (*Repo) Verification added in v0.0.6

func (r *Repo) Verification() *verificationRepository

func (*Repo) Webhook

func (r *Repo) Webhook() webhook.Repository

type Repository

type Repository interface {
	// Core repositories
	User() *UserRepository
	Session() *SessionRepository
	SocialAccount() SocialAccountRepository

	// Authentication & Security
	APIKey() *APIKeyRepository
	Audit() *AuditRepository
	Device() *DeviceRepository
	JWTKey() *JWTKeyRepository
	Role() *RoleRepository
	Security() *SecurityRepository
	Policy() *PolicyRepository
	Permission() *PermissionRepository
	RolePermission() *RolePermissionRepository
	UserRole() *UserRoleRepository
	UserBan() *UserBanRepository

	Notification() notification.Repository

	// OAuth & SSO
	OAuthToken() *OAuthTokenRepository
	OAuthClient() *OAuthClientRepository
	AuthorizationCode() *AuthorizationCodeRepository
	SSOProvider() *SSOProviderRepository
	SocialProviderConfig() SocialProviderConfigRepository

	// Multi-factor Authentication
	TwoFA() *TwoFARepository
	MFA() *MFARepository
	EmailOTP() *EmailOTPRepository

	// Authentication Methods
	Phone() *PhoneRepository
	MagicLink() *MagicLinkRepository

	// Identity & Verification
	IdentityVerification() *IdentityVerificationRepository
	Verification() *verificationRepository

	// App & Environment
	App() *AppRepository
	Environment() environment.Repository

	// Impersonation
	Impersonation() *ImpersonationRepository

	// Forms & Webhooks
	Forms() forms.Repository
	Webhook() webhook.Repository

	// Organization repositories
	Organization() organization.OrganizationRepository
	OrganizationMember() organization.MemberRepository
	OrganizationTeam() organization.TeamRepository
	OrganizationInvitation() organization.InvitationRepository
}

func NewRepo

func NewRepo(db *bun.DB) Repository

type RolePermissionRepository

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

RolePermissionRepository handles role-permission relationships

func NewRolePermissionRepository

func NewRolePermissionRepository(db *bun.DB) *RolePermissionRepository

func (*RolePermissionRepository) AssignPermission

func (r *RolePermissionRepository) AssignPermission(ctx context.Context, roleID, permissionID xid.ID) error

func (*RolePermissionRepository) GetPermissionRoles

func (r *RolePermissionRepository) GetPermissionRoles(ctx context.Context, permissionID xid.ID) ([]*schema.Role, error)

func (*RolePermissionRepository) GetRolePermissions

func (r *RolePermissionRepository) GetRolePermissions(ctx context.Context, roleID xid.ID) ([]*schema.Permission, error)

func (*RolePermissionRepository) ReplaceRolePermissions

func (r *RolePermissionRepository) ReplaceRolePermissions(ctx context.Context, roleID xid.ID, permissionIDs []xid.ID) error

func (*RolePermissionRepository) UnassignPermission

func (r *RolePermissionRepository) UnassignPermission(ctx context.Context, roleID, permissionID xid.ID) error

type RoleRepository

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

RoleRepository provides basic CRUD for roles

func NewRoleRepository

func NewRoleRepository(db *bun.DB) *RoleRepository

func (*RoleRepository) CloneRole

func (r *RoleRepository) CloneRole(ctx context.Context, templateID xid.ID, orgID xid.ID, customName *string) (*schema.Role, error)

CloneRole clones a role template for an organization

func (*RoleRepository) Create

func (r *RoleRepository) Create(ctx context.Context, role *schema.Role) error

func (*RoleRepository) Delete

func (r *RoleRepository) Delete(ctx context.Context, roleID xid.ID) error

func (*RoleRepository) FindByID

func (r *RoleRepository) FindByID(ctx context.Context, roleID xid.ID) (*schema.Role, error)

func (*RoleRepository) FindByNameAndApp

func (r *RoleRepository) FindByNameAndApp(ctx context.Context, name string, appID xid.ID) (*schema.Role, error)

FindByNameAndApp finds a role by name within an app (deprecated, use FindByNameAppEnv)

func (*RoleRepository) FindByNameAppEnv added in v0.0.5

func (r *RoleRepository) FindByNameAppEnv(ctx context.Context, name string, appID, envID xid.ID) (*schema.Role, error)

FindByNameAppEnv finds a role by name, app, and environment

func (*RoleRepository) FindDuplicateRoles added in v0.0.5

func (r *RoleRepository) FindDuplicateRoles(ctx context.Context) ([]schema.Role, error)

FindDuplicateRoles identifies roles that would violate the new uniqueness constraints

func (*RoleRepository) GetOrgRoleWithPermissions

func (r *RoleRepository) GetOrgRoleWithPermissions(ctx context.Context, roleID xid.ID) (*schema.Role, error)

GetOrgRoleWithPermissions gets a role with its permissions loaded

func (*RoleRepository) GetOrgRoles

func (r *RoleRepository) GetOrgRoles(ctx context.Context, orgID, envID xid.ID) ([]*schema.Role, error)

GetOrgRoles gets all roles specific to an organization

func (*RoleRepository) GetOwnerRole

func (r *RoleRepository) GetOwnerRole(ctx context.Context, appID, envID xid.ID) (*schema.Role, error)

GetOwnerRole gets the role marked as the owner role for an app

func (*RoleRepository) GetRoleTemplates

func (r *RoleRepository) GetRoleTemplates(ctx context.Context, appID, envID xid.ID) ([]*schema.Role, error)

GetRoleTemplates gets all role templates for an app (templates have organization_id = NULL and is_template = true)

func (*RoleRepository) ListByOrg

func (r *RoleRepository) ListByOrg(ctx context.Context, orgID *string) ([]schema.Role, error)

func (*RoleRepository) Update

func (r *RoleRepository) Update(ctx context.Context, role *schema.Role) error

type SSOProviderRepository

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

SSOProviderRepository provides persistence for SSO provider configurations with multi-tenant scoping

func NewSSOProviderRepository

func NewSSOProviderRepository(db *bun.DB) *SSOProviderRepository

func (*SSOProviderRepository) Create

Create inserts a new SSOProvider record

func (*SSOProviderRepository) Delete

func (r *SSOProviderRepository) Delete(ctx context.Context, id xid.ID) error

Delete removes an SSO provider by ID within the tenant scope

func (*SSOProviderRepository) FindByDomain

func (r *SSOProviderRepository) FindByDomain(ctx context.Context, domain string) ([]*schema.SSOProvider, error)

FindByDomain returns SSO providers matching a domain within the tenant scope

func (*SSOProviderRepository) FindByProviderID

func (r *SSOProviderRepository) FindByProviderID(ctx context.Context, providerID string) (*schema.SSOProvider, error)

FindByProviderID returns an SSOProvider by ProviderID within the tenant scope

func (*SSOProviderRepository) List

List returns all SSO providers within the tenant scope

func (*SSOProviderRepository) Upsert

Upsert creates or updates an SSOProvider by ProviderID within the tenant scope

type SecurityRepository

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

SecurityRepository implements core security repository using Bun

func NewSecurityRepository

func NewSecurityRepository(db *bun.DB) *SecurityRepository

func (*SecurityRepository) Create

type SessionRepository

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

SessionRepository is a Bun-backed implementation of core session repository

func NewSessionRepository

func NewSessionRepository(db *bun.DB) *SessionRepository

func (*SessionRepository) CleanupExpiredSessions

func (r *SessionRepository) CleanupExpiredSessions(ctx context.Context) (int, error)

CleanupExpiredSessions removes expired sessions

func (*SessionRepository) CountSessions

func (r *SessionRepository) CountSessions(ctx context.Context, appID xid.ID, userID *xid.ID) (int, error)

CountSessions counts sessions for an app and optionally a user

func (*SessionRepository) CreateSession

func (r *SessionRepository) CreateSession(ctx context.Context, s *schema.Session) error

CreateSession inserts a new session

func (*SessionRepository) FindSessionByID

func (r *SessionRepository) FindSessionByID(ctx context.Context, id xid.ID) (*schema.Session, error)

FindSessionByID retrieves a session by id

func (*SessionRepository) FindSessionByRefreshToken added in v0.0.3

func (r *SessionRepository) FindSessionByRefreshToken(ctx context.Context, refreshToken string) (*schema.Session, error)

FindSessionByRefreshToken retrieves a session by refresh token

func (*SessionRepository) FindSessionByToken

func (r *SessionRepository) FindSessionByToken(ctx context.Context, token string) (*schema.Session, error)

FindSessionByToken retrieves a session by token

func (*SessionRepository) ListSessions

ListSessions lists sessions with filtering and pagination

func (*SessionRepository) RefreshSessionTokens added in v0.0.3

func (r *SessionRepository) RefreshSessionTokens(ctx context.Context, id xid.ID, newAccessToken string, accessTokenExpiresAt time.Time, newRefreshToken string, refreshTokenExpiresAt time.Time) error

RefreshSessionTokens updates both access and refresh tokens for a session

func (*SessionRepository) RevokeSession

func (r *SessionRepository) RevokeSession(ctx context.Context, token string) error

RevokeSession deletes a session by token

func (*SessionRepository) RevokeSessionByID

func (r *SessionRepository) RevokeSessionByID(ctx context.Context, id xid.ID) error

RevokeSessionByID deletes a session by id

func (*SessionRepository) UpdateSessionExpiry added in v0.0.3

func (r *SessionRepository) UpdateSessionExpiry(ctx context.Context, id xid.ID, expiresAt time.Time) error

UpdateSessionExpiry updates the expiry time of a session (for sliding window renewal)

type SocialAccountRepository

type SocialAccountRepository interface {
	Create(ctx context.Context, account *schema.SocialAccount) error
	FindByID(ctx context.Context, id xid.ID) (*schema.SocialAccount, error)
	FindByUserAndProvider(ctx context.Context, userID xid.ID, provider string) (*schema.SocialAccount, error)
	FindByProviderAndProviderID(ctx context.Context, provider, providerID string, appID xid.ID, userOrganizationID *xid.ID) (*schema.SocialAccount, error)
	FindByUser(ctx context.Context, userID xid.ID) ([]*schema.SocialAccount, error)
	Update(ctx context.Context, account *schema.SocialAccount) error
	Delete(ctx context.Context, id xid.ID) error
	Unlink(ctx context.Context, userID xid.ID, provider string) error
}

SocialAccountRepository handles social account persistence

func NewSocialAccountRepository

func NewSocialAccountRepository(db *bun.DB) SocialAccountRepository

type SocialProviderConfigRepository added in v0.0.3

type SocialProviderConfigRepository interface {
	// Create creates a new social provider config
	Create(ctx context.Context, config *schema.SocialProviderConfig) error

	// FindByID finds a config by ID
	FindByID(ctx context.Context, id xid.ID) (*schema.SocialProviderConfig, error)

	// FindByProvider finds a config by app, environment, and provider name
	FindByProvider(ctx context.Context, appID, envID xid.ID, providerName string) (*schema.SocialProviderConfig, error)

	// ListByEnvironment lists all configs for an environment
	ListByEnvironment(ctx context.Context, appID, envID xid.ID) ([]*schema.SocialProviderConfig, error)

	// ListEnabledByEnvironment lists only enabled configs for an environment
	ListEnabledByEnvironment(ctx context.Context, appID, envID xid.ID) ([]*schema.SocialProviderConfig, error)

	// Update updates an existing config
	Update(ctx context.Context, config *schema.SocialProviderConfig) error

	// Delete soft-deletes a config by ID
	Delete(ctx context.Context, id xid.ID) error

	// HardDelete permanently deletes a config
	HardDelete(ctx context.Context, id xid.ID) error

	// SetEnabled enables or disables a provider
	SetEnabled(ctx context.Context, id xid.ID, enabled bool) error

	// CountByEnvironment counts providers for an environment
	CountByEnvironment(ctx context.Context, appID, envID xid.ID) (int, error)

	// ExistsByProvider checks if a provider config exists for the environment
	ExistsByProvider(ctx context.Context, appID, envID xid.ID, providerName string) (bool, error)
}

SocialProviderConfigRepository handles social provider config persistence

func NewSocialProviderConfigRepository added in v0.0.3

func NewSocialProviderConfigRepository(db *bun.DB) SocialProviderConfigRepository

NewSocialProviderConfigRepository creates a new social provider config repository

type TeamRepository

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

TeamRepository handles team data access using schema models

func NewTeamRepository

func NewTeamRepository(db *bun.DB) *TeamRepository

NewTeamRepository creates a new team repository

func (*TeamRepository) AddMember

func (r *TeamRepository) AddMember(ctx context.Context, teamID, memberID xid.ID, role string) error

AddMember adds a member to a team

func (*TeamRepository) CountByApp

func (r *TeamRepository) CountByApp(ctx context.Context, appID xid.ID) (int, error)

CountByApp returns the total number of teams in an app

func (*TeamRepository) CountTeamMembers

func (r *TeamRepository) CountTeamMembers(ctx context.Context, teamID xid.ID) (int, error)

CountTeamMembers returns the total number of members in a team

func (*TeamRepository) Create

func (r *TeamRepository) Create(ctx context.Context, team *schema.Team) error

Create creates a new team

func (*TeamRepository) Delete

func (r *TeamRepository) Delete(ctx context.Context, id xid.ID) error

Delete deletes a team

func (*TeamRepository) FindByExternalID added in v0.0.2

func (r *TeamRepository) FindByExternalID(ctx context.Context, appID xid.ID, externalID string) (*schema.Team, error)

FindByExternalID finds a team by external ID (for SCIM lookups)

func (*TeamRepository) FindByID

func (r *TeamRepository) FindByID(ctx context.Context, id xid.ID) (*schema.Team, error)

FindByID finds a team by ID

func (*TeamRepository) ListByApp

func (r *TeamRepository) ListByApp(ctx context.Context, appID xid.ID, limit, offset int) ([]*schema.Team, int64, error)

ListByApp lists teams by app with pagination

func (*TeamRepository) ListMembers

func (r *TeamRepository) ListMembers(ctx context.Context, teamID xid.ID) ([]*schema.Member, error)

ListMembers lists members of a team

func (*TeamRepository) RemoveMember

func (r *TeamRepository) RemoveMember(ctx context.Context, teamID, memberID xid.ID) error

RemoveMember removes a member from a team

func (*TeamRepository) Update

func (r *TeamRepository) Update(ctx context.Context, team *schema.Team) error

Update updates a team

type TwoFARepository

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

TwoFARepository provides persistence for 2FA entities

func NewTwoFARepository

func NewTwoFARepository(db *bun.DB) *TwoFARepository

func (*TwoFARepository) CreateBackupCodes

func (r *TwoFARepository) CreateBackupCodes(ctx context.Context, userID xid.ID, hashes []string) error

CreateBackupCodes stores hashed backup codes

func (*TwoFARepository) CreateOTPCode

func (r *TwoFARepository) CreateOTPCode(ctx context.Context, userID xid.ID, codeHash string, expiresAt time.Time) error

OTP codes

func (*TwoFARepository) DB

func (r *TwoFARepository) DB() *bun.DB

DB returns the underlying database connection for advanced operations

func (*TwoFARepository) DisableSecret

func (r *TwoFARepository) DisableSecret(ctx context.Context, userID xid.ID) error

DisableSecret disables 2FA for a user

func (*TwoFARepository) GetSecret

func (r *TwoFARepository) GetSecret(ctx context.Context, userID xid.ID) (*schema.TwoFASecret, error)

GetSecret returns a user's 2FA secret

func (*TwoFARepository) IsTrustedDevice

func (r *TwoFARepository) IsTrustedDevice(ctx context.Context, userID xid.ID, deviceID string, now time.Time) (bool, error)

func (*TwoFARepository) MarkTrustedDevice

func (r *TwoFARepository) MarkTrustedDevice(ctx context.Context, userID xid.ID, deviceID string, expiresAt time.Time) error

Trusted devices

func (*TwoFARepository) UpsertSecret

func (r *TwoFARepository) UpsertSecret(ctx context.Context, userID xid.ID, method, secret string, enabled bool) error

UpsertSecret sets or updates a user's 2FA secret

func (*TwoFARepository) VerifyAndUseBackupCode

func (r *TwoFARepository) VerifyAndUseBackupCode(ctx context.Context, userID xid.ID, hash string) (bool, error)

VerifyAndUseBackupCode verifies a backup code hash and marks it used

func (*TwoFARepository) VerifyOTPCode

func (r *TwoFARepository) VerifyOTPCode(ctx context.Context, userID xid.ID, codeHash string, now time.Time, maxAttempts int) (bool, error)

type UserBanRepository

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

UserBanRepository implements the user.BanRepository interface using Bun ORM

func NewUserBanRepository

func NewUserBanRepository(db *bun.DB) *UserBanRepository

NewUserBanRepository creates a new user ban repository

func (*UserBanRepository) CreateBan

func (r *UserBanRepository) CreateBan(ctx context.Context, ban *schema.UserBan) error

CreateBan creates a new user ban record

func (*UserBanRepository) FindActiveBan

func (r *UserBanRepository) FindActiveBan(ctx context.Context, userID string) (*schema.UserBan, error)

FindActiveBan finds an active ban for a user

func (*UserBanRepository) FindBanByID

func (r *UserBanRepository) FindBanByID(ctx context.Context, banID string) (*schema.UserBan, error)

FindBanByID finds a ban by its ID

func (*UserBanRepository) FindBansByUser

func (r *UserBanRepository) FindBansByUser(ctx context.Context, userID string) ([]*schema.UserBan, error)

FindBansByUser finds all bans for a user (active and inactive)

func (*UserBanRepository) UpdateBan

func (r *UserBanRepository) UpdateBan(ctx context.Context, ban *schema.UserBan) error

UpdateBan updates an existing ban record

type UserRepository

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

UserRepository is a Bun-backed implementation of core user repository

func NewUserRepository

func NewUserRepository(db *bun.DB) *UserRepository

NewUserRepository creates a new user repository

func (*UserRepository) CountUsers

func (r *UserRepository) CountUsers(ctx context.Context, filter *core.CountUsersFilter) (int, error)

CountUsers counts users with filtering

func (*UserRepository) Create

func (r *UserRepository) Create(ctx context.Context, user *schema.User) error

Create inserts a new user

func (*UserRepository) Delete

func (r *UserRepository) Delete(ctx context.Context, id xid.ID) error

Delete deletes a user by ID

func (*UserRepository) FindByAppAndEmail

func (r *UserRepository) FindByAppAndEmail(ctx context.Context, appID xid.ID, email string) (*schema.User, error)

FindByAppAndEmail finds a user by app ID and email (app-scoped search)

func (*UserRepository) FindByEmail

func (r *UserRepository) FindByEmail(ctx context.Context, email string) (*schema.User, error)

FindByEmail finds a user by email (global search, not app-scoped)

func (*UserRepository) FindByID

func (r *UserRepository) FindByID(ctx context.Context, id xid.ID) (*schema.User, error)

FindByID finds a user by ID

func (*UserRepository) FindByUsername

func (r *UserRepository) FindByUsername(ctx context.Context, username string) (*schema.User, error)

FindByUsername finds a user by username

func (*UserRepository) ListUsers

ListUsers lists users with pagination and filtering

func (*UserRepository) Update

func (r *UserRepository) Update(ctx context.Context, user *schema.User) error

Update updates a user

type UserRoleRepository

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

UserRoleRepository manages user-role assignments

func NewUserRoleRepository

func NewUserRoleRepository(db *bun.DB) *UserRoleRepository

func (*UserRoleRepository) Assign

func (r *UserRoleRepository) Assign(ctx context.Context, userID, roleID, orgID xid.ID) error

Assign links a user to a role within an organization

func (*UserRoleRepository) AssignAppLevel added in v0.0.7

func (r *UserRoleRepository) AssignAppLevel(ctx context.Context, userID, roleID, appID xid.ID) error

AssignAppLevel assigns a role at app-level (not org-scoped)

func (*UserRoleRepository) AssignBatch added in v0.0.7

func (r *UserRoleRepository) AssignBatch(ctx context.Context, userID xid.ID, roleIDs []xid.ID, orgID xid.ID) error

AssignBatch assigns multiple roles to a single user in an organization

func (*UserRoleRepository) AssignBulk added in v0.0.7

func (r *UserRoleRepository) AssignBulk(ctx context.Context, userIDs []xid.ID, roleID xid.ID, orgID xid.ID) (map[xid.ID]error, error)

AssignBulk assigns a single role to multiple users in an organization

func (*UserRoleRepository) ClearUserRolesInApp added in v0.0.7

func (r *UserRoleRepository) ClearUserRolesInApp(ctx context.Context, userID, appID xid.ID) error

ClearUserRolesInApp removes all roles from a user in an app

func (*UserRoleRepository) ClearUserRolesInOrg added in v0.0.7

func (r *UserRoleRepository) ClearUserRolesInOrg(ctx context.Context, userID, orgID xid.ID) error

ClearUserRolesInOrg removes all roles from a user in an organization

func (*UserRoleRepository) CopyRoles added in v0.0.7

func (r *UserRoleRepository) CopyRoles(ctx context.Context, userID, sourceOrgID, targetOrgID xid.ID, roleIDs []xid.ID) error

CopyRoles duplicates roles from one org to another (insert only)

func (*UserRoleRepository) ListAllUserRolesInApp added in v0.0.7

func (r *UserRoleRepository) ListAllUserRolesInApp(ctx context.Context, appID, envID xid.ID) ([]schema.UserRole, error)

ListAllUserRolesInApp lists all user-role assignments in an app across all orgs (admin view)

func (*UserRoleRepository) ListAllUserRolesInOrg added in v0.0.7

func (r *UserRoleRepository) ListAllUserRolesInOrg(ctx context.Context, orgID, envID xid.ID) ([]schema.UserRole, error)

ListAllUserRolesInOrg lists all user-role assignments in an organization (admin view)

func (*UserRoleRepository) ListRolesForUser

func (r *UserRoleRepository) ListRolesForUser(ctx context.Context, userID xid.ID, orgID *xid.ID) ([]schema.Role, error)

ListRolesForUser returns roles assigned to a user, optionally filtered by org

func (*UserRoleRepository) ListRolesForUserInApp added in v0.0.7

func (r *UserRoleRepository) ListRolesForUserInApp(ctx context.Context, userID, appID, envID xid.ID) ([]schema.Role, error)

ListRolesForUserInApp gets roles for a specific user across all orgs in an app with environment filter

func (*UserRoleRepository) ListRolesForUserInOrg added in v0.0.7

func (r *UserRoleRepository) ListRolesForUserInOrg(ctx context.Context, userID, orgID, envID xid.ID) ([]schema.Role, error)

ListRolesForUserInOrg gets roles for a specific user in an organization with environment filter

func (*UserRoleRepository) ReplaceUserRoles added in v0.0.7

func (r *UserRoleRepository) ReplaceUserRoles(ctx context.Context, userID, orgID xid.ID, newRoleIDs []xid.ID) error

ReplaceUserRoles atomically replaces all user roles in an org with a new set

func (*UserRoleRepository) TransferRoles added in v0.0.7

func (r *UserRoleRepository) TransferRoles(ctx context.Context, userID, sourceOrgID, targetOrgID xid.ID, roleIDs []xid.ID) error

TransferRoles moves roles from one org to another (delete + insert in transaction)

func (*UserRoleRepository) Unassign

func (r *UserRoleRepository) Unassign(ctx context.Context, userID, roleID, orgID xid.ID) error

Unassign removes a user-role assignment within an organization

func (*UserRoleRepository) UnassignBatch added in v0.0.7

func (r *UserRoleRepository) UnassignBatch(ctx context.Context, userID xid.ID, roleIDs []xid.ID, orgID xid.ID) error

UnassignBatch removes multiple roles from a single user in an organization

func (*UserRoleRepository) UnassignBulk added in v0.0.7

func (r *UserRoleRepository) UnassignBulk(ctx context.Context, userIDs []xid.ID, roleID xid.ID, orgID xid.ID) (map[xid.ID]error, error)

UnassignBulk removes a single role from multiple users in an organization

type UsernameRepository

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

UsernameRepository handles username plugin-specific database operations

func NewUsernameRepository

func NewUsernameRepository(db *bun.DB) *UsernameRepository

NewUsernameRepository creates a new username repository

func (*UsernameRepository) CheckPasswordInHistory

func (r *UsernameRepository) CheckPasswordInHistory(ctx context.Context, userID xid.ID, password string, limit int) (bool, error)

CheckPasswordInHistory checks if a password matches any in the user's history

func (*UsernameRepository) CleanupExpiredLockouts

func (r *UsernameRepository) CleanupExpiredLockouts(ctx context.Context) error

CleanupExpiredLockouts removes expired lockouts

func (*UsernameRepository) CleanupOldFailedAttempts

func (r *UsernameRepository) CleanupOldFailedAttempts(ctx context.Context, before time.Time) error

CleanupOldFailedAttempts removes failed attempts older than the specified duration

func (*UsernameRepository) CleanupOldPasswordHistory

func (r *UsernameRepository) CleanupOldPasswordHistory(ctx context.Context, userID xid.ID, keepCount int) error

CleanupOldPasswordHistory removes old password history entries beyond the limit

func (*UsernameRepository) ClearFailedAttempts

func (r *UsernameRepository) ClearFailedAttempts(ctx context.Context, username string, appID xid.ID) error

ClearFailedAttempts removes all failed attempts for a username

func (*UsernameRepository) GetFailedAttempts

func (r *UsernameRepository) GetFailedAttempts(ctx context.Context, username string, appID xid.ID, since time.Time) (int, error)

GetFailedAttempts returns the number of failed attempts for a username within a time window

func (*UsernameRepository) GetPasswordHistory

func (r *UsernameRepository) GetPasswordHistory(ctx context.Context, userID xid.ID, limit int) ([]string, error)

GetPasswordHistory retrieves the most recent password hashes for a user

func (*UsernameRepository) IsAccountLocked

func (r *UsernameRepository) IsAccountLocked(ctx context.Context, userID xid.ID) (bool, *time.Time, error)

IsAccountLocked checks if a user account is currently locked Returns true if locked, the locked_until time, and any error

func (*UsernameRepository) LockAccount

func (r *UsernameRepository) LockAccount(ctx context.Context, userID xid.ID, duration time.Duration, reason string) error

LockAccount locks a user account for a specified duration

func (*UsernameRepository) RecordFailedAttempt

func (r *UsernameRepository) RecordFailedAttempt(ctx context.Context, username string, appID xid.ID, ip, ua string) error

RecordFailedAttempt records a failed login attempt

func (*UsernameRepository) SavePasswordHistory

func (r *UsernameRepository) SavePasswordHistory(ctx context.Context, userID xid.ID, passwordHash string) error

SavePasswordHistory saves a password hash to history

func (*UsernameRepository) UnlockAccount

func (r *UsernameRepository) UnlockAccount(ctx context.Context, userID xid.ID) error

UnlockAccount removes all active lockouts for a user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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