Expand description
SQLx support for gatekeep query lowering and durable decision audit.
This crate lowers a gatekeep::ResidualPolicy into trusted SQL fragments
that can be appended to a sqlx::QueryBuilder.
It also provides Dovecote-backed gatekeep::AuditSink implementations for
Postgres, SQLite, and MySQL. Run the selected Dovecote migration, call
the adapter’s check_schema, configure an application-owned absolute event
source, and pass the sink to gatekeep_axum::Gatekeeper.
Gatekeep does not maintain a SQL audit table. Each decision is serialized as
one complete Dovecote event with a pending delivery. Use the concrete
record_decision_audit_in_transaction method when application writes and
the audit event need one caller-owned transaction.
Structs§
- Decision
Audit Config - Configuration required to write Gatekeep audit events.
- NoGrade
Projection - Projection that rejects grade lowering.
- Ordinal
Projection - Outcome projection backed by
SqlOutcome. - PgDovecote
Audit - Postgres Dovecote-backed decision audit sink.
- Postgres
Backend - Postgres backend marker.
- Sqlx
Fragment - Trusted SQL plus ordered bind values for one
SQLxbackend. - Sqlx
Lowerer SQLxlowerer for gatekeep residual policies.- Tenant
Column - Validated application-owned table and column names for tenant filtering.
Enums§
- Attempt
Audit Event Error - Invalid attempt event or durable payload.
- Decision
Audit Config Error - Errors while validating the application-owned audit source.
- Decision
Audit Decode Error - Errors returned while decoding a Dovecote event as a Gatekeep decision audit entry.
- Decision
Audit Event Error - Errors while converting a typed Gatekeep entry into a validated Dovecote event.
- Legacy
Decision Audit Decode Error - Errors returned while decoding a historical audit event explicitly.
- PgDovecote
Audit Error - Errors returned by
PgDovecoteAudit. - Sqlx
Driver - Supported
SQLxdatabase driver. - Sqlx
Driver Error - Database driver configuration error.
- Sqlx
Value - Scalar value carried by a lowered SQL fragment.
- Tenant
Column Error - Failure while constructing a tenant column identifier.
- Tenant
Identifier Part - Which component of a qualified tenant column failed validation.
Constants§
- ATTEMPT_
AUDIT_ EVENT_ TYPE - Event type distinguishing failed attempts from completed policy decisions.
- DECISION_
AUDIT_ CONTENT_ TYPE - The explicit JSON content type used for every decision audit event.
- DECISION_
AUDIT_ EVENT_ TYPE - The durable event type for Gatekeep decision audit events.
- DEFAULT_
AUDIT_ STREAM - The default Dovecote stream for Gatekeep decision audit events.
- MAX_
TENANT_ IDENTIFIER_ BYTES - Maximum portable SQL identifier length accepted by this adapter.
Traits§
- Gatekeep
Sqlx Backend SQLxbackend supported by gatekeep lowering.- Outcome
Projection - Projection strategy for turning outcomes into SQL fragments.
- PgFact
Predicates - Maps a residual fact to a trusted Postgres predicate over the candidate row.
- SqlOutcome
- Maps a policy outcome to a total-order SQL ordinal.
- Sqlx
Fact Predicates - Maps a residual fact to a trusted predicate over the candidate row.
Functions§
- decode_
authorization_ attempt - Decodes a bounded attempt event and verifies scope, identity, time and type.
- decode_
decision_ audit - Decodes a tenant-scoped Dovecote page item into a typed Gatekeep audit entry.
- decode_
legacy_ decision_ audit - Decodes a historical Gatekeep audit event without treating it as current.
- infer_
enabled_ driver_ from_ url - Infers the
SQLxdriver from a database URL orSQLx-styleSQLitememory URL. - validate_
database_ url_ for_ backend - Validates that a database URL matches a selected backend.
Type Aliases§
- PgFragment
- Trusted Postgres SQL plus ordered bind values.
- PgLowerer
- Postgres lowerer for gatekeep residual policies.
- PgValue
- Postgres scalar value carried by a lowered SQL fragment.