Skip to main content

Crate gatekeep_sqlx

Crate gatekeep_sqlx 

Source
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§

DecisionAuditConfig
Configuration required to write Gatekeep audit events.
NoGradeProjection
Projection that rejects grade lowering.
OrdinalProjection
Outcome projection backed by SqlOutcome.
PgDovecoteAudit
Postgres Dovecote-backed decision audit sink.
PostgresBackend
Postgres backend marker.
SqlxFragment
Trusted SQL plus ordered bind values for one SQLx backend.
SqlxLowerer
SQLx lowerer for gatekeep residual policies.
TenantColumn
Validated application-owned table and column names for tenant filtering.

Enums§

AttemptAuditEventError
Invalid attempt event or durable payload.
DecisionAuditConfigError
Errors while validating the application-owned audit source.
DecisionAuditDecodeError
Errors returned while decoding a Dovecote event as a Gatekeep decision audit entry.
DecisionAuditEventError
Errors while converting a typed Gatekeep entry into a validated Dovecote event.
LegacyDecisionAuditDecodeError
Errors returned while decoding a historical audit event explicitly.
PgDovecoteAuditError
Errors returned by PgDovecoteAudit.
SqlxDriver
Supported SQLx database driver.
SqlxDriverError
Database driver configuration error.
SqlxValue
Scalar value carried by a lowered SQL fragment.
TenantColumnError
Failure while constructing a tenant column identifier.
TenantIdentifierPart
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§

GatekeepSqlxBackend
SQLx backend supported by gatekeep lowering.
OutcomeProjection
Projection strategy for turning outcomes into SQL fragments.
PgFactPredicates
Maps a residual fact to a trusted Postgres predicate over the candidate row.
SqlOutcome
Maps a policy outcome to a total-order SQL ordinal.
SqlxFactPredicates
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 SQLx driver from a database URL or SQLx-style SQLite memory 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.