pub struct SecurityManager { /* private fields */ }Expand description
Security manager for cluster authentication and authorization.
Implementations§
Source§impl SecurityManager
impl SecurityManager
Sourcepub fn create_user(
&self,
username: String,
email: Option<String>,
roles: Vec<RoleId>,
) -> Result<UserId>
pub fn create_user( &self, username: String, email: Option<String>, roles: Vec<RoleId>, ) -> Result<UserId>
Create a new user.
Sourcepub fn authenticate(
&self,
user_id: &UserId,
_credentials: &str,
) -> Result<Token>
pub fn authenticate( &self, user_id: &UserId, _credentials: &str, ) -> Result<Token>
Authenticate user and create session.
Sourcepub fn validate_session(&self, token: &Token) -> Result<UserId>
pub fn validate_session(&self, token: &Token) -> Result<UserId>
Validate a session token.
Sourcepub fn check_permission(
&self,
user_id: &UserId,
permission: &Permission,
) -> Result<bool>
pub fn check_permission( &self, user_id: &UserId, permission: &Permission, ) -> Result<bool>
Check if user has permission.
Sourcepub fn require_permission(
&self,
user_id: &UserId,
permission: &Permission,
) -> Result<()>
pub fn require_permission( &self, user_id: &UserId, permission: &Permission, ) -> Result<()>
Require permission (throws error if not authorized).
Sourcepub fn create_role(
&self,
id: RoleId,
name: String,
permissions: HashSet<Permission>,
) -> Result<()>
pub fn create_role( &self, id: RoleId, name: String, permissions: HashSet<Permission>, ) -> Result<()>
Create or update a role.
Sourcepub fn assign_role(&self, user_id: &UserId, role_id: &RoleId) -> Result<()>
pub fn assign_role(&self, user_id: &UserId, role_id: &RoleId) -> Result<()>
Assign role to user.
Sourcepub fn store_secret(
&self,
key: String,
value: String,
expires_at: Option<SystemTime>,
) -> Result<()>
pub fn store_secret( &self, key: String, value: String, expires_at: Option<SystemTime>, ) -> Result<()>
Store a secret.
Sourcepub fn get_secret(&self, key: &str) -> Result<String>
pub fn get_secret(&self, key: &str) -> Result<String>
Retrieve a secret.
Sourcepub fn audit(
&self,
user_id: UserId,
action: String,
resource: String,
result: AuditResult,
details: Option<String>,
)
pub fn audit( &self, user_id: UserId, action: String, resource: String, result: AuditResult, details: Option<String>, )
Log an audit entry.
Sourcepub fn get_audit_log(&self, limit: usize) -> Vec<AuditEntry>
pub fn get_audit_log(&self, limit: usize) -> Vec<AuditEntry>
Get audit log.
Sourcepub fn get_stats(&self) -> SecurityStats
pub fn get_stats(&self) -> SecurityStats
Get security statistics.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SecurityManager
impl !RefUnwindSafe for SecurityManager
impl Send for SecurityManager
impl Sync for SecurityManager
impl Unpin for SecurityManager
impl UnsafeUnpin for SecurityManager
impl !UnwindSafe for SecurityManager
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