pub enum SecurityPolicy {
ReadOnly,
ReadWrite {
writable_records: HashSet<String>,
},
}Expand description
Security policy for remote access
Defines which operations are permitted and for which records.
Variants§
ReadOnly
Read-only access (list, get, subscribe)
This is the default and recommended policy for most deployments. No write operations are permitted.
ReadWrite
Read-write access with explicit per-record opt-in
Write operations (record.set) are only allowed for records
whose RecordKey is in the writable_records set.
Implementations§
Source§impl SecurityPolicy
impl SecurityPolicy
Sourcepub fn read_write() -> Self
pub fn read_write() -> Self
Creates a read-write policy with no writable records initially
Sourcepub fn allow_write_key(&mut self, key: impl Into<String>)
pub fn allow_write_key(&mut self, key: impl Into<String>)
Adds a record key to the writable set
Only has effect for ReadWrite policies. Panics if policy is ReadOnly.
Sourcepub fn with_writable_key(self, key: impl Into<String>) -> Self
pub fn with_writable_key(self, key: impl Into<String>) -> Self
Adds a record key to the writable set (builder pattern)
§Panics
Panics if called on a ReadOnly policy
Sourcepub fn is_writable_key(&self, key: &str) -> bool
pub fn is_writable_key(&self, key: &str) -> bool
Checks if a record key is writable
Sourcepub fn permissions(&self) -> &[&str]
pub fn permissions(&self) -> &[&str]
Returns the list of granted permissions
Sourcepub fn writable_records(&self) -> Vec<String>
pub fn writable_records(&self) -> Vec<String>
Returns the list of writable record keys (for ReadWrite policy)
Sourcepub fn writable_record_keys(&self) -> Vec<StringKey>
pub fn writable_record_keys(&self) -> Vec<StringKey>
Returns the list of writable record keys as StringKeys
Trait Implementations§
Source§impl Clone for SecurityPolicy
impl Clone for SecurityPolicy
Source§fn clone(&self) -> SecurityPolicy
fn clone(&self) -> SecurityPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more