Documentation
¶
Index ¶
- type Config
- type Repo
- func (r *Repo) CleanupAttempts(ctx context.Context, before time.Time) error
- func (r *Repo) ConfirmMFA(ctx context.Context, userID string, now time.Time) error
- func (r *Repo) ConfirmSessionMFA(ctx context.Context, sessionID string, now time.Time) error
- func (r *Repo) ConfirmSessionPassword(ctx context.Context, sessionID string, now time.Time) error
- func (r *Repo) ConsumeBackupCode(ctx context.Context, userID, codeHash string, now time.Time) (bool, error)
- func (r *Repo) ConsumeChallenge(ctx context.Context, id string) error
- func (r *Repo) CountRecentAttempts(ctx context.Context, ipHash, identity string, since time.Time) (int, error)
- func (r *Repo) CreateChallenge(ctx context.Context, email, kind, secretHash string, expiresAt time.Time) error
- func (r *Repo) CreateImpersonatedSession(ctx context.Context, userID, impersonatedBy, ipHash, userAgent string, ...) (string, time.Time, error)
- func (r *Repo) CreatePAT(ctx context.Context, userID, name, tokenHash, prefix string, ...) (app.PAT, error)
- func (r *Repo) CreateSession(ctx context.Context, in webx.SessionCreate) (string, time.Time, error)
- func (r *Repo) CreateUserWithPassword(ctx context.Context, email, passwordHash, displayName string) (app.User, error)
- func (r *Repo) CreateUserWithPasswordTx(ctx context.Context, tx pgx.Tx, email, passwordHash, displayName string) (app.User, error)
- func (r *Repo) DeleteFedProvider(ctx context.Context, workspaceID string) error
- func (r *Repo) DeleteMFA(ctx context.Context, userID string) error
- func (r *Repo) EarliestRecentAttempt(ctx context.Context, ipHash, identity string, since time.Time) (time.Time, bool, error)
- func (r *Repo) FindOAuthAccount(ctx context.Context, provider, subject string) (string, bool, error)
- func (r *Repo) GetFedProvider(ctx context.Context, workspaceID string) (*app.FedProviderRow, bool, error)
- func (r *Repo) GetMFA(ctx context.Context, userID string) (secretSealed string, confirmedAt *time.Time, ok bool, err error)
- func (r *Repo) GetUser(ctx context.Context, id string) (app.User, error)
- func (r *Repo) GetUserByEmail(ctx context.Context, email string) (app.User, bool, error)
- func (r *Repo) IncChallengeAttempts(ctx context.Context, id string) error
- func (r *Repo) LatestPendingChallenge(ctx context.Context, email, kind string) (*app.Challenge, error)
- func (r *Repo) LinkOAuthAccount(ctx context.Context, provider, subject, userID, emailAtLink string, ...) error
- func (r *Repo) ListPATs(ctx context.Context, userID string) ([]app.PAT, error)
- func (r *Repo) ListUserSessions(ctx context.Context, userID string) ([]app.SessionInfo, error)
- func (r *Repo) ListUsersByIDs(ctx context.Context, ids []string) ([]app.User, error)
- func (r *Repo) RecordAttempt(ctx context.Context, ipHash, identity string, success bool, at time.Time) error
- func (r *Repo) RenewSession(ctx context.Context, token string, now time.Time) (time.Time, bool, error)
- func (r *Repo) ReplaceBackupCodes(ctx context.Context, userID string, codeHashes []string, now time.Time) error
- func (r *Repo) ResolvePAT(ctx context.Context, token string, now time.Time) (*webx.Principal, error)
- func (r *Repo) RevokeAllUserSessions(ctx context.Context, userID string) error
- func (r *Repo) RevokePAT(ctx context.Context, userID, patID string, now time.Time) error
- func (r *Repo) RevokeSession(ctx context.Context, token string) error
- func (r *Repo) RevokeUserSessionByID(ctx context.Context, userID, sessionID string, now time.Time) error
- func (r *Repo) RunInTx(ctx context.Context, fn func(ctx context.Context, tx pgx.Tx) error) error
- func (r *Repo) SetEmailVerified(ctx context.Context, userID string, at time.Time) error
- func (r *Repo) SetPasswordHash(ctx context.Context, userID, passwordHash string, now time.Time) error
- func (r *Repo) SoftDeleteUserTx(ctx context.Context, tx pgx.Tx, userID string, now time.Time) error
- func (r *Repo) UpdateProfile(ctx context.Context, id, displayName, avatarURL string) (app.User, error)
- func (r *Repo) UpsertFedProvider(ctx context.Context, row *app.FedProviderRow, now time.Time) error
- func (r *Repo) UpsertPendingMFA(ctx context.Context, userID, secretSealed string, now time.Time) error
- func (r *Repo) UpsertUserByEmail(ctx context.Context, email string, now time.Time) (app.User, error)
- func (r *Repo) VerifySession(ctx context.Context, token string, now time.Time) (*webx.Principal, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
func (*Repo) CleanupAttempts ¶
func (*Repo) ConfirmMFA ¶ added in v0.5.0
func (*Repo) ConfirmSessionMFA ¶ added in v0.5.0
ConfirmSessionMFA stamps mfa_confirmed_at on a live session — the second freshness fact (POST /auth/verify-mfa step-up), symmetric to ConfirmSessionPassword.
func (*Repo) ConfirmSessionPassword ¶ added in v0.4.0
func (*Repo) ConsumeBackupCode ¶ added in v0.5.0
func (r *Repo) ConsumeBackupCode(ctx context.Context, userID, codeHash string, now time.Time) (bool, error)
ConsumeBackupCode marks one pending code consumed in a single conditional UPDATE — consume-once under concurrency without an application-level lock.
func (*Repo) ConsumeChallenge ¶
func (*Repo) CountRecentAttempts ¶
func (*Repo) CreateChallenge ¶
func (*Repo) CreateImpersonatedSession ¶
func (*Repo) CreateSession ¶
func (*Repo) CreateUserWithPassword ¶
func (*Repo) CreateUserWithPasswordTx ¶
func (*Repo) DeleteFedProvider ¶
func (*Repo) EarliestRecentAttempt ¶ added in v0.11.3
func (*Repo) FindOAuthAccount ¶
func (*Repo) GetFedProvider ¶
func (*Repo) GetUserByEmail ¶
func (*Repo) IncChallengeAttempts ¶
func (*Repo) LatestPendingChallenge ¶
func (*Repo) LinkOAuthAccount ¶
func (r *Repo) LinkOAuthAccount(ctx context.Context, provider, subject, userID, emailAtLink string, now time.Time) error
LinkOAuthAccount 绑定 (provider, subject) → user。旧实现 ON CONFLICT DO NOTHING 静默吞掉「已绑到另一用户」的冲突(OA-1,oauth-admin-config- audit-2026-10-31):同一 provider 账号在改邮箱瞬间并发两次回调会造出 第二个用户且登录成功,而 oauth_account 行永久指向第一个用户——下次 登录回到旧账号,身份漂移且无告警。现在冲突时回读既有行比对 user_id: 一致(幂等重放)正常返回;不一致 fail-closed 报 app.ErrOAuthLinkConflict, 本次登录失败、用户重点一次即走 FindOAuthAccount 命中既有绑定。
func (*Repo) ListUserSessions ¶
func (*Repo) ListUsersByIDs ¶ added in v0.5.0
ListUsersByIDs batch-resolves users (aifengkong #7); unlike GetUser it returns rows regardless of status (a disabled author still deserves a name on audit trails) and skips missing ids instead of failing.