mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-10-03 12:01:58 +00:00
refactor(security): move all database access into pkg/security/lookup
pkg/security no longer contains SQL. Every provider calls a store interface
from lookup, implemented by a procedure backend (Postgres stored procedures,
the default there) and a direct backend (dialect-driven SQL for postgres,
sqlite, mysql and mssql with configurable table and column names).
- add sectypes, lookup, lookup/{dialect,procedure,direct,backends,ddl,conformance}
- split totp and providers sub packages out of the core package
- replace SQLNames/TableNames/QueryMode with lookup.Config (see breaking_changes.md)
- direct backend now covers column/row security and API-key login
- move txsettings SQL to lookup.ApplyTxSettings; remove password.go
- move schema scripts under lookup/, add reference DDL per dialect
- add a shared conformance suite; run it on sqlite, and on Postgres in a
podman/docker container (RESOLVESPEC_TEST_CONTAINERS=1)
- fix procedure schema bugs found on real Postgres: duplicate p_data
parameter, JSON null arrays, expires_at timezone casts, passkey list
GROUP BY, missing resolvespec_passkey_login; accept zone-less timestamps
This commit is contained in:
@@ -2,6 +2,7 @@ package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -38,6 +39,15 @@ type Database interface {
|
||||
DriverName() string
|
||||
}
|
||||
|
||||
// SQLDBProvider is implemented by adapters that wrap a *sql.DB (directly or through an ORM).
|
||||
// It lets packages that work on database/sql, such as pkg/security/lookup, reuse the
|
||||
// connection an application already configured. Transaction adapters do not implement it.
|
||||
type SQLDBProvider interface {
|
||||
// SQLDB returns the current underlying *sql.DB. After an adapter reconnects it
|
||||
// returns the new handle, so do not cache it across reconnects.
|
||||
SQLDB() *sql.DB
|
||||
}
|
||||
|
||||
// SelectQuery interface for building SELECT queries (compatible with both GORM and Bun)
|
||||
type SelectQuery interface {
|
||||
Model(model interface{}) SelectQuery
|
||||
|
||||
Reference in New Issue
Block a user