pub struct AccessController { /* private fields */ }Expand description
Shared, cheaply clonable handle to the live access-control state.
None/absent controller or a disabled config means the feature is off
and every surface behaves exactly as before. All mutations validate,
bump the revision, and persist to the configured TOML path (if any).
Implementations§
Source§impl AccessController
impl AccessController
Sourcepub fn new(config: AccessControlConfig) -> Result<Self, AccessConfigError>
pub fn new(config: AccessControlConfig) -> Result<Self, AccessConfigError>
Create a controller from a validated config.
Sourcepub fn disabled() -> Self
pub fn disabled() -> Self
Create a disabled controller (feature off until an admin enables it).
Sourcepub fn load_or_default(
path: impl Into<PathBuf>,
) -> Result<Self, AccessConfigError>
pub fn load_or_default( path: impl Into<PathBuf>, ) -> Result<Self, AccessConfigError>
Load a controller from a TOML file, remembering the path so future admin mutations persist back to it. A missing file yields a default (disabled) config that is written on first mutation.
Sourcepub fn with_persist_path(self, path: impl Into<PathBuf>) -> Self
pub fn with_persist_path(self, path: impl Into<PathBuf>) -> Self
Set (or replace) the persistence path.
Sourcepub fn snapshot(&self) -> (Arc<AccessControlConfig>, u64)
pub fn snapshot(&self) -> (Arc<AccessControlConfig>, u64)
Current config and revision.
Sourcepub fn replace_config(
&self,
config: AccessControlConfig,
) -> Result<u64, AccessConfigError>
pub fn replace_config( &self, config: AccessControlConfig, ) -> Result<u64, AccessConfigError>
Replace the whole configuration (admin surface).
Sourcepub fn upsert_rule(&self, rule: AccessRule) -> Result<u64, AccessConfigError>
pub fn upsert_rule(&self, rule: AccessRule) -> Result<u64, AccessConfigError>
Insert or update one rule by id.
Sourcepub fn delete_rule(&self, rule_id: &str) -> Result<u64, AccessConfigError>
pub fn delete_rule(&self, rule_id: &str) -> Result<u64, AccessConfigError>
Delete one rule by id.
Sourcepub fn set_group(
&self,
name: &str,
group: AccessGroup,
) -> Result<u64, AccessConfigError>
pub fn set_group( &self, name: &str, group: AccessGroup, ) -> Result<u64, AccessConfigError>
Create or replace a group (the live per-user assignment surface).
Sourcepub fn delete_group(&self, name: &str) -> Result<u64, AccessConfigError>
pub fn delete_group(&self, name: &str) -> Result<u64, AccessConfigError>
Delete a group. Fails while rules still reference it.
Sourcepub fn set_enabled(&self, enabled: bool) -> Result<u64, AccessConfigError>
pub fn set_enabled(&self, enabled: bool) -> Result<u64, AccessConfigError>
Toggle enforcement. Enabling validates the anti-lockout invariant.
Sourcepub fn view_for_subject(&self, subject: Option<&str>) -> AccessView
pub fn view_for_subject(&self, subject: Option<&str>) -> AccessView
Build the per-request view for an authenticated subject (or None
for an open/unauthenticated console).
Sourcepub fn record_agent_attributes(&self, attributes: AgentResourceAttributes)
pub fn record_agent_attributes(&self, attributes: AgentResourceAttributes)
Refresh the cached resource attributes for one agent.
Sourcepub fn replace_agent_attributes(
&self,
attributes: impl IntoIterator<Item = AgentResourceAttributes>,
)
pub fn replace_agent_attributes( &self, attributes: impl IntoIterator<Item = AgentResourceAttributes>, )
Replace the entire attribute cache from a fresh roster projection.
Used by the per-request priming at the SSE/RPC/timeline seams: it both fills attributes for label/role evaluation and evicts entries for agents no longer in the roster, so a retired-then-reused identity can’t keep stale role/labels alive and the cache can’t grow without bound. A no-op when given an empty roster, so a transient empty projection never blanks a populated cache.
Trait Implementations§
Source§impl Clone for AccessController
impl Clone for AccessController
Source§fn clone(&self) -> AccessController
fn clone(&self) -> AccessController
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AccessController
impl RefUnwindSafe for AccessController
impl Send for AccessController
impl Sync for AccessController
impl Unpin for AccessController
impl UnsafeUnpin for AccessController
impl UnwindSafe for AccessController
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more