pub struct AdminOperations<'a> { /* private fields */ }Expand description
Focused advanced administration operations exposed from AuthFramework::admin.
These operations go beyond the everyday AuthorizationOperations surface and cover
ABAC policy management, permission delegation, role inheritance, resource registration,
and attribute-based access control.
Implementations§
Source§impl AdminOperations<'_>
impl AdminOperations<'_>
Sourcepub async fn set_role_inheritance(
&self,
child_role: &str,
parent_role: &str,
) -> Result<()>
pub async fn set_role_inheritance( &self, child_role: &str, parent_role: &str, ) -> Result<()>
Define a parent–child role inheritance relationship.
Sourcepub async fn create_abac_policy(
&self,
name: &str,
description: &str,
) -> Result<()>
pub async fn create_abac_policy( &self, name: &str, description: &str, ) -> Result<()>
Create an ABAC policy.
Sourcepub async fn map_user_attribute(
&self,
user_id: &str,
attribute: &str,
value: &str,
) -> Result<()>
pub async fn map_user_attribute( &self, user_id: &str, attribute: &str, value: &str, ) -> Result<()>
Map a user attribute used in ABAC policy evaluation.
Sourcepub async fn set_user_attributes(
&self,
user_id: &str,
attributes: &[(&str, &str)],
) -> Result<()>
pub async fn set_user_attributes( &self, user_id: &str, attributes: &[(&str, &str)], ) -> Result<()>
Set multiple user attributes in one call.
This is a convenience wrapper around map_user_attribute
for setting several ABAC attributes at once.
§Example
auth.admin().set_user_attributes("user-1", &[
("department", "engineering"),
("clearance", "top-secret"),
("location", "us-west-2"),
]).await?;Sourcepub async fn get_user_attribute(
&self,
user_id: &str,
attribute: &str,
) -> Result<Option<String>>
pub async fn get_user_attribute( &self, user_id: &str, attribute: &str, ) -> Result<Option<String>>
Get a user attribute value.
Sourcepub async fn check_dynamic_permission(
&self,
user_id: &str,
action: &str,
resource: &str,
context: HashMap<String, String>,
) -> Result<bool>
pub async fn check_dynamic_permission( &self, user_id: &str, action: &str, resource: &str, context: HashMap<String, String>, ) -> Result<bool>
Check a permission using dynamic ABAC context evaluation.
Prefer check_dynamic_permission_with_context
with a PermissionContext for a more readable API.
Sourcepub async fn check_dynamic_permission_with_context(
&self,
user_id: &str,
action: &str,
resource: &str,
context: PermissionContext,
) -> Result<bool>
pub async fn check_dynamic_permission_with_context( &self, user_id: &str, action: &str, resource: &str, context: PermissionContext, ) -> Result<bool>
Check a permission using dynamic ABAC context evaluation with a
PermissionContext.
§Example
use auth_framework::auth_operations::PermissionContext;
let ctx = PermissionContext::new()
.with_attribute("ip_location", "office")
.with_attribute("device_type", "trusted");
let allowed = auth.admin()
.check_dynamic_permission_with_context("user_123", "read", "docs", ctx)
.await?;Sourcepub async fn create_resource(&self, resource: &str) -> Result<()>
pub async fn create_resource(&self, resource: &str) -> Result<()>
Register a resource in the permission system.
Sourcepub async fn delegate(&self, req: DelegationRequest) -> Result<()>
pub async fn delegate(&self, req: DelegationRequest) -> Result<()>
Delegate a permission from one user to another using a DelegationRequest.
§Example
auth.admin()
.delegate(
DelegationRequest::new("admin_1", "user_2", "write", "reports")
.duration(Duration::from_secs(3600))
)
.await?;Auto Trait Implementations§
impl<'a> Freeze for AdminOperations<'a>
impl<'a> !RefUnwindSafe for AdminOperations<'a>
impl<'a> Send for AdminOperations<'a>
impl<'a> Sync for AdminOperations<'a>
impl<'a> Unpin for AdminOperations<'a>
impl<'a> UnsafeUnpin for AdminOperations<'a>
impl<'a> !UnwindSafe for AdminOperations<'a>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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