repository

package
v0.45.7 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRepositoryManager

func NewRepositoryManager(db *bun.DB) auth.RepositoryManager

Types

type IdentifierModel added in v0.44.0

type IdentifierModel struct {
	bun.BaseModel `bun:"table:user_identifiers"`

	ID         uuid.UUID      `bun:"id,pk,nullzero,type:uuid"`
	UserID     uuid.UUID      `bun:"user_id,notnull,type:uuid"`
	Provider   string         `bun:"provider,notnull"`
	Identifier string         `bun:"identifier,notnull"`
	Metadata   map[string]any `bun:"metadata,type:jsonb"`
	CreatedAt  time.Time      `bun:"created_at,default:current_timestamp"`
	UpdatedAt  time.Time      `bun:"updated_at,default:current_timestamp"`
}

type IdentifierStore added in v0.44.0

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

func NewIdentifierStore added in v0.44.0

func NewIdentifierStore(db *bun.DB) *IdentifierStore

func (*IdentifierStore) Bind added in v0.45.0

func (s *IdentifierStore) Bind(ctx context.Context, userID, provider, identifier string) error

func (*IdentifierStore) BindTx added in v0.45.0

func (s *IdentifierStore) BindTx(ctx context.Context, db bun.IDB, userID, provider, identifier string) error

func (*IdentifierStore) CreateUserAndBind added in v0.45.0

func (s *IdentifierStore) CreateUserAndBind(ctx context.Context, users auth.Users, user *auth.User, provider, identifier string) (*auth.User, error)

func (*IdentifierStore) Delete added in v0.44.0

func (s *IdentifierStore) Delete(ctx context.Context, userID, provider, identifier string) error

func (*IdentifierStore) FindUserID added in v0.44.0

func (s *IdentifierStore) FindUserID(ctx context.Context, provider, identifier string) (string, error)

func (*IdentifierStore) Upsert added in v0.44.0

func (s *IdentifierStore) Upsert(ctx context.Context, userID, provider, identifier string) error

func (*IdentifierStore) UpsertUserAndBind added in v0.45.0

func (s *IdentifierStore) UpsertUserAndBind(
	ctx context.Context,
	users auth.Users,
	user *auth.User,
	provider, identifier string,
) (*auth.User, error)

type LifecycleOperationModel added in v0.45.0

type LifecycleOperationModel struct {
	bun.BaseModel `bun:"table:lifecycle_operations"`

	OperationID                   string     `bun:"operation_id,pk"`
	Fingerprint                   string     `bun:"fingerprint,notnull"`
	Action                        string     `bun:"action,notnull"`
	LocalPhase                    string     `bun:"local_phase,notnull"`
	RemotePhase                   string     `bun:"remote_phase,notnull"`
	FreshnessPhase                string     `bun:"freshness_phase,notnull"`
	LocalStatus                   string     `bun:"local_status"`
	LocalSessionEffect            string     `bun:"local_session_effect"`
	RemoteStatus                  string     `bun:"remote_status"`
	RemoteRetryable               bool       `bun:"remote_retryable,notnull"`
	RemoteRequestFingerprint      string     `bun:"remote_request_fingerprint"`
	RemoteSessionEffect           string     `bun:"remote_session_effect"`
	RemoteResidualAccessExpiresAt *time.Time `bun:"remote_residual_access_expires_at"`
	FreshnessStatus               string     `bun:"freshness_status"`
	ProviderIdempotencyKey        string     `bun:"provider_idempotency_key,notnull"`
	LocalLeaseOwner               string     `bun:"local_lease_owner"`
	LocalLeaseUntil               *time.Time `bun:"local_lease_until"`
	RemoteAttempt                 int        `bun:"remote_attempt,notnull"`
	RemoteLeaseOwner              string     `bun:"remote_lease_owner"`
	RemoteLeaseUntil              *time.Time `bun:"remote_lease_until"`
	FreshnessLeaseOwner           string     `bun:"freshness_lease_owner"`
	FreshnessLeaseUntil           *time.Time `bun:"freshness_lease_until"`
	Revision                      int64      `bun:"revision,notnull"`
	Completed                     bool       `bun:"completed,notnull"`
	CreatedAt                     time.Time  `bun:"created_at,nullzero,notnull,default:current_timestamp"`
	UpdatedAt                     time.Time  `bun:"updated_at,nullzero,notnull,default:current_timestamp"`
}

type LifecycleOperationRepository added in v0.45.0

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

func NewLifecycleOperationRepository added in v0.45.0

func NewLifecycleOperationRepository(db *bun.DB) (*LifecycleOperationRepository, error)

func (*LifecycleOperationRepository) Advance added in v0.45.0

func (*LifecycleOperationRepository) Claim added in v0.45.0

func (*LifecycleOperationRepository) ClaimPending added in v0.45.0

func (*LifecycleOperationRepository) Durable added in v0.45.0

func (r *LifecycleOperationRepository) Durable() bool

func (*LifecycleOperationRepository) Load added in v0.45.0

type OIDCStateModel added in v0.45.0

type OIDCStateModel struct {
	bun.BaseModel `bun:"table:oidc_states"`

	StateHash          []byte    `bun:"state_hash,pk"`
	ProviderKey        string    `bun:"provider_key,notnull"`
	Nonce              string    `bun:"nonce,notnull"`
	VerifierVersion    uint8     `bun:"verifier_version,notnull"`
	VerifierAlgorithm  string    `bun:"verifier_algorithm,notnull"`
	VerifierKeyID      string    `bun:"verifier_key_id,notnull"`
	VerifierNonce      []byte    `bun:"verifier_nonce,notnull"`
	VerifierCiphertext []byte    `bun:"verifier_ciphertext,notnull"`
	RedirectTo         string    `bun:"redirect_to,notnull"`
	CreatedAt          time.Time `bun:"created_at,nullzero,notnull,default:current_timestamp"`
	ExpiresAt          time.Time `bun:"expires_at,notnull"`
}

type OIDCStateStore added in v0.45.0

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

OIDCStateStore preserves oidc.StateStore compatibility while providing durable, single-use, encrypted PKCE state.

func NewOIDCStateStore added in v0.45.0

func NewOIDCStateStore(db *bun.DB, cipher auth.TokenCipher) (*OIDCStateStore, error)

func (*OIDCStateStore) CleanupExpired added in v0.45.0

func (s *OIDCStateStore) CleanupExpired(ctx context.Context, before time.Time, limit int) (int64, error)

func (*OIDCStateStore) Consume added in v0.45.0

func (s *OIDCStateStore) Consume(ctx context.Context, rawState string) (oidc.StateRecord, error)

func (*OIDCStateStore) Save added in v0.45.0

func (s *OIDCStateStore) Save(ctx context.Context, record oidc.StateRecord) error

type ProviderSessionAuthorizationFenceModel added in v0.45.0

type ProviderSessionAuthorizationFenceModel struct {
	bun.BaseModel `bun:"table:provider_session_authorization_fences"`

	ApplicationSubject          string     `bun:"application_subject,pk,notnull"`
	TenantID                    string     `bun:"tenant_id,pk,notnull"`
	RequiredPermissionVersion   string     `bun:"required_permission_version,notnull"`
	PermissionVersionObservedAt *time.Time `bun:"permission_version_observed_at"`
	CreatedAt                   time.Time  `bun:"created_at,nullzero,notnull,default:current_timestamp"`
	UpdatedAt                   time.Time  `bun:"updated_at,nullzero,notnull,default:current_timestamp"`
}

type ProviderSessionLifecycleFenceModel added in v0.45.0

type ProviderSessionLifecycleFenceModel struct {
	bun.BaseModel `bun:"table:provider_session_lifecycle_fences"`

	ApplicationSubject   string     `bun:"application_subject,pk,notnull"`
	TenantID             string     `bun:"tenant_id,pk,notnull"`
	BlockedState         string     `bun:"blocked_state,notnull"`
	CredentialsNotBefore *time.Time `bun:"credentials_not_before"`
	EventObservedAt      *time.Time `bun:"event_observed_at"`
	Generation           int64      `bun:"generation,notnull"`
	CreatedAt            time.Time  `bun:"created_at,nullzero,notnull,default:current_timestamp"`
	UpdatedAt            time.Time  `bun:"updated_at,nullzero,notnull,default:current_timestamp"`
}

type ProviderSessionModel added in v0.45.0

type ProviderSessionModel struct {
	bun.BaseModel `bun:"table:provider_sessions"`

	ID                            string          `bun:"id,pk,type:uuid"`
	LocalSessionID                string          `bun:"local_session_id,notnull,type:uuid"`
	LookupHash                    []byte          `bun:"lookup_hash,notnull"`
	ApplicationSubject            string          `bun:"application_subject,notnull"`
	ProviderSubject               string          `bun:"provider_subject,notnull"`
	ProviderSessionID             string          `bun:"provider_session_id"`
	Host                          string          `bun:"host,notnull"`
	ApplicationID                 string          `bun:"application_id,notnull"`
	Environment                   string          `bun:"environment,notnull"`
	TenantID                      string          `bun:"tenant_id,notnull"`
	Provider                      string          `bun:"provider,notnull"`
	Issuer                        string          `bun:"issuer,notnull"`
	OAuthClientID                 string          `bun:"oauth_client_id,notnull"`
	Principal                     json.RawMessage `bun:"principal,type:jsonb,notnull"`
	Status                        string          `bun:"status,notnull"`
	TokenRevision                 int64           `bun:"token_revision,notnull"`
	CreatedAt                     time.Time       `bun:"created_at,nullzero,notnull,default:current_timestamp"`
	LastSeenAt                    time.Time       `bun:"last_seen_at,nullzero,notnull,default:current_timestamp"`
	IdleExpiresAt                 time.Time       `bun:"idle_expires_at,notnull"`
	MaxExpiresAt                  time.Time       `bun:"max_expires_at,notnull"`
	RefreshAttemptID              *string         `bun:"refresh_attempt_id"`
	RefreshBaseRevision           *int64          `bun:"refresh_base_revision"`
	RefreshLeaseUntil             *time.Time      `bun:"refresh_lease_until"`
	RevokedAt                     *time.Time      `bun:"revoked_at"`
	RevocationReason              string          `bun:"revocation_reason"`
	RevocationReasonFingerprint   string          `bun:"revocation_reason_fingerprint"`
	RemoteRevocationStatus        string          `bun:"remote_revocation_status"`
	RemoteRevocationRetryable     bool            `bun:"remote_revocation_retryable,notnull"`
	ResidualAccessExpiresAt       *time.Time      `bun:"residual_access_expires_at"`
	RemoteRevocationAttemptCount  int             `bun:"remote_revocation_attempt_count,notnull"`
	RemoteRevocationNextAttemptAt *time.Time      `bun:"remote_revocation_next_attempt_at"`
	RemoteRevocationLeaseOwner    string          `bun:"remote_revocation_lease_owner"`
	RemoteRevocationLeaseUntil    *time.Time      `bun:"remote_revocation_lease_until"`
	RemoteRevocationRevision      int64           `bun:"remote_revocation_revision,notnull"`
	RemoteRevocationSafeErrorCode string          `bun:"remote_revocation_safe_error_code"`
	RemoteRevocationWorkExpiresAt *time.Time      `bun:"remote_revocation_work_expires_at"`
	RemoteRevocationTerminalAt    *time.Time      `bun:"remote_revocation_terminal_at"`
	UpdatedAt                     time.Time       `bun:"updated_at,nullzero,notnull,default:current_timestamp"`
}

type ProviderSessionRepository added in v0.45.0

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

func NewProviderSessionRepository added in v0.45.0

func NewProviderSessionRepository(db *bun.DB) (*ProviderSessionRepository, error)

func (*ProviderSessionRepository) AdvanceProviderSessionLifecycle added in v0.45.0

AdvanceProviderSessionLifecycle serializes session admission and security-restricting lifecycle transitions through the same subject fence.

func (*ProviderSessionRepository) ClaimRefresh added in v0.45.0

func (r *ProviderSessionRepository) ClaimRefresh(ctx context.Context, sessionID string, expectedRevision int64, attemptID string, lease time.Duration) (auth.ProviderRefreshClaim, error)

func (*ProviderSessionRepository) ClaimRemoteRevocations added in v0.45.0

func (*ProviderSessionRepository) Cleanup added in v0.45.0

func (*ProviderSessionRepository) CommitRefresh added in v0.45.0

func (*ProviderSessionRepository) CompleteRemoteRevocation added in v0.45.0

func (r *ProviderSessionRepository) CompleteRemoteRevocation(
	ctx context.Context,
	completion auth.ProviderRemoteRevocationCompletion,
) error

func (*ProviderSessionRepository) Create added in v0.45.0

func (*ProviderSessionRepository) Load added in v0.45.0

func (*ProviderSessionRepository) MarkRefreshUncertain added in v0.45.0

func (r *ProviderSessionRepository) MarkRefreshUncertain(ctx context.Context, sessionID, attemptID string, baseRevision int64, reason string) error

func (*ProviderSessionRepository) ReplaceCiphertext added in v0.45.0

func (r *ProviderSessionRepository) ReplaceCiphertext(ctx context.Context, sessionID string, expectedRevision int64, envelope auth.TokenEnvelope) (auth.ProviderSession, error)

func (*ProviderSessionRepository) Resolve added in v0.45.0

func (*ProviderSessionRepository) Revoke added in v0.45.0

func (r *ProviderSessionRepository) Revoke(ctx context.Context, sessionID, reason string) (auth.ProviderSession, bool, error)

func (*ProviderSessionRepository) RevokeScope added in v0.45.0

func (*ProviderSessionRepository) RevokeUser added in v0.45.0

func (r *ProviderSessionRepository) RevokeUser(ctx context.Context, applicationSubject, reason string) ([]auth.ProviderSession, error)

func (*ProviderSessionRepository) RotateHandle added in v0.45.0

func (r *ProviderSessionRepository) RotateHandle(ctx context.Context, sessionID string, expectedRevision int64, oldLookupHash, newLookupHash []byte) (auth.ProviderSession, error)

func (*ProviderSessionRepository) UpdateRemoteRevocation added in v0.45.0

func (r *ProviderSessionRepository) UpdateRemoteRevocation(ctx context.Context, sessionID string, outcome auth.ProviderRemoteRevocationOutcome) error

type ProviderSessionTokenModel added in v0.45.0

type ProviderSessionTokenModel struct {
	bun.BaseModel `bun:"table:provider_session_tokens"`

	SessionID         string     `bun:"session_id,pk,type:uuid"`
	TokenRevision     int64      `bun:"token_revision,notnull"`
	EnvelopeVersion   uint8      `bun:"envelope_version,notnull"`
	EnvelopeAlgorithm string     `bun:"envelope_algorithm,notnull"`
	KeyID             string     `bun:"key_id,notnull"`
	Nonce             []byte     `bun:"nonce,notnull"`
	Ciphertext        []byte     `bun:"ciphertext,notnull"`
	AccessExpiresAt   *time.Time `bun:"access_expires_at"`
	RefreshExpiresAt  *time.Time `bun:"refresh_expires_at"`
	RetainUntil       *time.Time `bun:"retain_until"`
	CreatedAt         time.Time  `bun:"created_at,nullzero,notnull,default:current_timestamp"`
	UpdatedAt         time.Time  `bun:"updated_at,nullzero,notnull,default:current_timestamp"`
}

type SocialAccountModel added in v0.24.0

type SocialAccountModel struct {
	bun.BaseModel `bun:"table:social_accounts"`

	ID             uuid.UUID      `bun:"id,pk,nullzero,type:uuid"`
	UserID         uuid.UUID      `bun:"user_id,notnull,type:uuid"`
	Provider       string         `bun:"provider,notnull"`
	ProviderUserID string         `bun:"provider_user_id,notnull"`
	Email          string         `bun:"email"`
	Name           string         `bun:"name"`
	Username       string         `bun:"username"`
	AvatarURL      string         `bun:"avatar_url"`
	AccessToken    string         `bun:"access_token"`
	RefreshToken   string         `bun:"refresh_token"`
	TokenExpiresAt *time.Time     `bun:"token_expires_at"`
	ProfileData    map[string]any `bun:"profile_data,type:jsonb"`
	CreatedAt      time.Time      `bun:"created_at,default:current_timestamp"`
	UpdatedAt      time.Time      `bun:"updated_at,default:current_timestamp"`
}

SocialAccountModel is the Bun model for social accounts.

type SocialAccountRepository added in v0.24.0

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

SocialAccountRepository implements social.SocialAccountRepository using Bun.

func NewSocialAccountRepository added in v0.24.0

func NewSocialAccountRepository(db *bun.DB) *SocialAccountRepository

NewSocialAccountRepository creates a new repository.

func (*SocialAccountRepository) Delete added in v0.24.0

func (r *SocialAccountRepository) Delete(ctx context.Context, id string) error

Delete implements social.SocialAccountRepository.

func (*SocialAccountRepository) DeleteByUserAndProvider added in v0.24.0

func (r *SocialAccountRepository) DeleteByUserAndProvider(ctx context.Context, userID, provider string) error

DeleteByUserAndProvider implements social.SocialAccountRepository.

func (*SocialAccountRepository) FindByProviderID added in v0.24.0

func (r *SocialAccountRepository) FindByProviderID(ctx context.Context, provider, providerUserID string) (*social.SocialAccount, error)

FindByProviderID implements social.SocialAccountRepository.

func (*SocialAccountRepository) FindByUserID added in v0.24.0

func (r *SocialAccountRepository) FindByUserID(ctx context.Context, userID string) ([]*social.SocialAccount, error)

FindByUserID implements social.SocialAccountRepository.

func (*SocialAccountRepository) Upsert added in v0.24.0

Upsert implements social.SocialAccountRepository.

Jump to

Keyboard shortcuts

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