pub struct RlsConfig {
pub tenant_column: String,
pub session_variable: String,
pub application_role: Option<String>,
pub tables: HashSet<String>,
pub excluded_tables: HashSet<String>,
pub allow_bypass: bool,
pub policy_prefix: String,
}Expand description
Configuration for PostgreSQL RLS.
Fields§
§tenant_column: StringThe tenant ID column name.
session_variable: StringPostgreSQL setting name for current tenant (e.g., “app.current_tenant”).
application_role: Option<String>Role to apply policies to.
tables: HashSet<String>Tables to enable RLS on.
excluded_tables: HashSet<String>Tables excluded from RLS (e.g., shared lookup tables).
allow_bypass: boolWhether to use BYPASSRLS for admin operations.
policy_prefix: StringPolicy name prefix.
Implementations§
Source§impl RlsConfig
impl RlsConfig
Sourcepub fn new(tenant_column: impl Into<String>) -> Self
pub fn new(tenant_column: impl Into<String>) -> Self
Create a new RLS config with the given tenant column.
Sourcepub fn with_session_variable(self, var: impl Into<String>) -> Self
pub fn with_session_variable(self, var: impl Into<String>) -> Self
Set the session variable name.
Sourcepub fn add_tables<I, S>(self, tables: I) -> Self
pub fn add_tables<I, S>(self, tables: I) -> Self
Add multiple tables for RLS.
Sourcepub fn exclude_table(self, table: impl Into<String>) -> Self
pub fn exclude_table(self, table: impl Into<String>) -> Self
Exclude a table from RLS.
Sourcepub fn without_bypass(self) -> Self
pub fn without_bypass(self) -> Self
Disable bypass for admin.
Sourcepub fn with_policy_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_policy_prefix(self, prefix: impl Into<String>) -> Self
Set the policy prefix.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RlsConfig
impl RefUnwindSafe for RlsConfig
impl Send for RlsConfig
impl Sync for RlsConfig
impl Unpin for RlsConfig
impl UnwindSafe for RlsConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more