Interact with SpiceDB Seamlessly from within PostgreSQL using the SpiceDB Foreign Data Wrapper
Blog post from AuthZed
SpiceDB has introduced a Foreign Data Wrapper (FDW) for PostgreSQL, allowing real-time authorization context from SpiceDB to integrate into Postgres queries without data duplication, policy rewriting, or embedded authorization logic. Starting with version 1.49.0, this FDW enables PostgreSQL to query SpiceDB at runtime by exposing permissions and relationships as foreign tables supported by SpiceDB's APIs. This integration aims to provide a unified access point for both application and permission data, translating SQL operations into live SpiceDB API calls, leveraging its scalability and optimizations. While the FDW does not completely resolve the dual-write issue, as writes to relationships are executed in SpiceDB's own transaction, it reduces the impact by rolling back the surrounding PostgreSQL transaction if a write fails. Although still experimental, the FDW has been designed with real-world use cases in mind, and users are encouraged to try it out and provide feedback as it progresses in development.