Documentation
¶
Index ¶
- Variables
- func OpenDB(dbPath string) (*sql.DB, error)
- func OpenSerialConn(dbPath string) (*sql.DB, error)
- type AuthStore
- func (s *AuthStore) AssignAgent(ctx context.Context, userID string, agentID string) error
- func (s *AuthStore) CreatePolicy(ctx context.Context, p auth.Policy) (auth.Policy, error)
- func (s *AuthStore) CreateUserToken(ctx context.Context, token auth.UserToken) (auth.UserToken, error)
- func (s *AuthStore) DeletePolicy(ctx context.Context, id string) error
- func (s *AuthStore) GetActiveAutoUserToken(ctx context.Context, userID string) (auth.UserToken, error)
- func (s *AuthStore) GetActiveUserTokenByHash(ctx context.Context, tokenHash string) (auth.UserToken, error)
- func (s *AuthStore) GetPolicy(ctx context.Context, id string) (auth.Policy, error)
- func (s *AuthStore) GetUserTokenByHash(ctx context.Context, tokenHash string) (auth.UserToken, error)
- func (s *AuthStore) ListAgentUserIDs(ctx context.Context, agentID string) ([]string, error)
- func (s *AuthStore) ListEnabledPolicies(ctx context.Context) ([]auth.Policy, error)
- func (s *AuthStore) ListPolicies(ctx context.Context) ([]auth.Policy, error)
- func (s *AuthStore) ListUserAgentIDs(ctx context.Context, userID string) ([]string, error)
- func (s *AuthStore) RemoveAgent(ctx context.Context, userID string, agentID string) error
- func (s *AuthStore) RevokeUserToken(ctx context.Context, id string) (int64, error)
- func (s *AuthStore) RotateUserToken(ctx context.Context, id string) (int64, error)
- func (s *AuthStore) UpdatePolicy(ctx context.Context, p auth.Policy) error
- func (s *AuthStore) UpdateUserTokenLastUsed(ctx context.Context, id string) (int64, error)
- type OIDCStore
- func (s *OIDCStore) AssignAgent(ctx context.Context, userID, agentID string) error
- func (s *OIDCStore) BeginAuthTx(ctx context.Context) (auth.AuthStores, func() error, func(), error)
- func (s *OIDCStore) CountUsers(ctx context.Context) (int64, error)
- func (s *OIDCStore) CreateChannelIdentity(ctx context.Context, i auth.ChannelIdentity) (auth.ChannelIdentity, error)
- func (s *OIDCStore) CreateCredential(ctx context.Context, c auth.Credential) (auth.Credential, error)
- func (s *OIDCStore) CreateLoginIdentity(ctx context.Context, i auth.LoginIdentity) (auth.LoginIdentity, error)
- func (s *OIDCStore) CreateSession(ctx context.Context, sess auth.Session) (auth.Session, error)
- func (s *OIDCStore) CreateUser(ctx context.Context, u auth.User) (auth.User, error)
- func (s *OIDCStore) DeleteChannelIdentity(ctx context.Context, id string) error
- func (s *OIDCStore) DeleteCredential(ctx context.Context, userID string) error
- func (s *OIDCStore) DeleteExpiredSessions(ctx context.Context) error
- func (s *OIDCStore) DeleteSession(ctx context.Context, id string) error
- func (s *OIDCStore) DeleteUser(ctx context.Context, id string) error
- func (s *OIDCStore) DeleteUserSessions(ctx context.Context, userID string) error
- func (s *OIDCStore) GetChannelIdentity(ctx context.Context, id string) (auth.ChannelIdentity, error)
- func (s *OIDCStore) GetChannelIdentityByPlatform(ctx context.Context, platform, externalID string) (auth.ChannelIdentity, error)
- func (s *OIDCStore) GetCredentialByUserID(ctx context.Context, userID string) (auth.Credential, error)
- func (s *OIDCStore) GetLoginIdentityByProvider(ctx context.Context, provider, providerSubject string) (auth.LoginIdentity, error)
- func (s *OIDCStore) GetSession(ctx context.Context, id string) (auth.Session, error)
- func (s *OIDCStore) GetSessionByTokenHash(ctx context.Context, tokenHash string) (auth.Session, error)
- func (s *OIDCStore) GetUser(ctx context.Context, id string) (auth.User, error)
- func (s *OIDCStore) GetUserByEmail(ctx context.Context, email string) (auth.User, error)
- func (s *OIDCStore) GetVaultUser(ctx context.Context, id string) (sqlc.VaultUser, error)
- func (s *OIDCStore) ListActiveUserIDs(ctx context.Context) ([]string, error)
- func (s *OIDCStore) ListAgentUserIDs(ctx context.Context, agentID string) ([]string, error)
- func (s *OIDCStore) ListChannelIdentitiesByUser(ctx context.Context, userID string) ([]auth.ChannelIdentity, error)
- func (s *OIDCStore) ListLoginIdentitiesByUser(ctx context.Context, userID string) ([]auth.LoginIdentity, error)
- func (s *OIDCStore) ListSessionsByUser(ctx context.Context, userID string) ([]auth.Session, error)
- func (s *OIDCStore) ListUserAgentIDs(ctx context.Context, userID string) ([]string, error)
- func (s *OIDCStore) ListUsers(ctx context.Context) ([]auth.User, error)
- func (s *OIDCStore) ListUsersPaged(ctx context.Context, limit, offset int64) ([]auth.User, error)
- func (s *OIDCStore) RemoveAgent(ctx context.Context, userID, agentID string) error
- func (s *OIDCStore) UpdateChannelIdentityExternalID(ctx context.Context, id, externalID string) error
- func (s *OIDCStore) UpdateCredentialHash(ctx context.Context, userID, passwordHash string) error
- func (s *OIDCStore) UpdateLoginIdentity(ctx context.Context, i auth.LoginIdentity) error
- func (s *OIDCStore) UpdateSessionExpiry(ctx context.Context, id string, expiresAt time.Time) error
- func (s *OIDCStore) UpdateUser(ctx context.Context, u auth.User) error
- func (s *OIDCStore) UpdateUserActive(ctx context.Context, userID string, isActive bool) error
- func (s *OIDCStore) UpdateUserAgeKeys(ctx context.Context, userID, publicKey, privateKey string) error
- func (s *OIDCStore) UpdateUserDefaultAgent(ctx context.Context, userID, agentID string) error
- func (s *OIDCStore) UpdateUserNotifyIdentity(ctx context.Context, userID string, identityID *string) error
- func (s *OIDCStore) UpdateUserRole(ctx context.Context, userID string, role string) error
Constants ¶
This section is empty.
Variables ¶
var MigrationsFS embed.FS
MigrationsFS holds Atlas migration files. Embed the entire directory so it works even when no migrations exist yet.
var ( // RecallyArticleFTSSchema is exported so recally store tests, which // assemble their schema by hand instead of running migrations, can create // the index and triggers their search queries depend on. //go:embed schemas/tables/recally_article_fts.sql RecallyArticleFTSSchema string )
FTS5 indexes live outside the Atlas migration pipeline because Atlas's embedded dev SQLite lacks the fts5 module. The DDL (virtual tables + sync triggers) is kept in the sqlc schema dir so generated queries can reference the virtual tables, and is applied here at startup instead.
Functions ¶
func OpenDB ¶
OpenDB opens a SQLite database at the given path, configures it (WAL mode, foreign keys, busy timeout) and runs migrations. The parent directory is created if it doesn't exist.
func OpenSerialConn ¶ added in v0.41.0
OpenSerialConn opens a second handle to an already-migrated SQLite database capped at a single connection. Write-heavy subsystems (the memory provider) run on this handle so their writes queue in Go as a fast FIFO instead of fighting over SQLite's single write lock across many pooled connections — which otherwise burns the busy_timeout and starves the shared read pool.
The caller must have run OpenDB on the same path first; this handle does not migrate. The DSN carries the same pragmas (WAL, busy_timeout, foreign keys), and WAL lets this writer run concurrently with readers on the main pool.
Types ¶
type AuthStore ¶
type AuthStore struct {
*OIDCStore
// contains filtered or unexported fields
}
AuthStore implements auth.AuthStore using sqlc queries backed by SQLite. It embeds OIDCStore to satisfy all new auth store interfaces so that gateway.go can pass a single *AuthStore to all wiring points without knowing about the split between sqlc-backed and raw-SQL-backed stores.
func NewAuthStore ¶
NewAuthStore creates a new AuthStore wrapping the given database connection.
func (*AuthStore) AssignAgent ¶
func (*AuthStore) CreatePolicy ¶
func (*AuthStore) CreateUserToken ¶
func (*AuthStore) DeletePolicy ¶
func (*AuthStore) GetActiveAutoUserToken ¶
func (*AuthStore) GetActiveUserTokenByHash ¶
func (*AuthStore) GetUserTokenByHash ¶
func (*AuthStore) ListAgentUserIDs ¶
func (*AuthStore) ListEnabledPolicies ¶
func (*AuthStore) ListPolicies ¶
func (*AuthStore) ListUserAgentIDs ¶
func (*AuthStore) RemoveAgent ¶
func (*AuthStore) RevokeUserToken ¶
func (*AuthStore) RotateUserToken ¶
func (*AuthStore) UpdatePolicy ¶
type OIDCStore ¶ added in v0.38.0
type OIDCStore struct {
// contains filtered or unexported fields
}
OIDCStore implements auth store interfaces using raw SQL against the OIDC tables (auth_user, auth_identity, auth_session, channel_identity, auth_credential).
func NewOIDCStore ¶ added in v0.38.0
NewOIDCStore creates an OIDCStore backed by the given database connection.
func (*OIDCStore) AssignAgent ¶ added in v0.38.0
func (*OIDCStore) BeginAuthTx ¶ added in v0.38.0
BeginAuthTx starts a database transaction and returns tx-scoped copies of all auth stores. Implements auth.Transactioner so AuthService.ProcessOIDCLogin can run the entire login flow atomically.
func (*OIDCStore) CountUsers ¶ added in v0.38.0
func (*OIDCStore) CreateChannelIdentity ¶ added in v0.38.0
func (s *OIDCStore) CreateChannelIdentity(ctx context.Context, i auth.ChannelIdentity) (auth.ChannelIdentity, error)
func (*OIDCStore) CreateCredential ¶ added in v0.38.0
func (s *OIDCStore) CreateCredential(ctx context.Context, c auth.Credential) (auth.Credential, error)
func (*OIDCStore) CreateLoginIdentity ¶ added in v0.38.0
func (s *OIDCStore) CreateLoginIdentity(ctx context.Context, i auth.LoginIdentity) (auth.LoginIdentity, error)
func (*OIDCStore) CreateSession ¶ added in v0.38.0
func (*OIDCStore) CreateUser ¶ added in v0.38.0
func (*OIDCStore) DeleteChannelIdentity ¶ added in v0.38.0
func (*OIDCStore) DeleteCredential ¶ added in v0.38.0
func (*OIDCStore) DeleteExpiredSessions ¶ added in v0.38.0
func (*OIDCStore) DeleteSession ¶ added in v0.38.0
func (*OIDCStore) DeleteUser ¶ added in v0.38.0
func (*OIDCStore) DeleteUserSessions ¶ added in v0.38.0
func (*OIDCStore) GetChannelIdentity ¶ added in v0.38.0
func (*OIDCStore) GetChannelIdentityByPlatform ¶ added in v0.38.0
func (*OIDCStore) GetCredentialByUserID ¶ added in v0.38.0
func (*OIDCStore) GetLoginIdentityByProvider ¶ added in v0.38.0
func (*OIDCStore) GetSession ¶ added in v0.38.0
func (*OIDCStore) GetSessionByTokenHash ¶ added in v0.38.0
func (*OIDCStore) GetUserByEmail ¶ added in v0.38.0
func (*OIDCStore) GetVaultUser ¶ added in v0.38.0
GetVaultUser returns the age key fields for a user. Satisfies vault.DB.