pub struct AuthManager { /* private fields */ }Expand description
The main authentication and authorization manager
Implementations§
Source§impl AuthManager
impl AuthManager
Sourcepub fn new(config: AuthConfig) -> Self
pub fn new(config: AuthConfig) -> Self
Create a new authentication manager
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create with default config
Sourcepub fn with_auth_enabled() -> Self
pub fn with_auth_enabled() -> Self
Create an auth manager with authentication enabled
Sourcepub fn create_principal(
&self,
name: &str,
password: &str,
principal_type: PrincipalType,
roles: HashSet<String>,
) -> AuthResult<()>
pub fn create_principal( &self, name: &str, password: &str, principal_type: PrincipalType, roles: HashSet<String>, ) -> AuthResult<()>
Create a new principal (user or service account)
Sourcepub fn delete_principal(&self, name: &str) -> AuthResult<()>
pub fn delete_principal(&self, name: &str) -> AuthResult<()>
Delete a principal
Sourcepub fn get_principal(&self, name: &str) -> Option<Principal>
pub fn get_principal(&self, name: &str) -> Option<Principal>
Get a principal by name
Sourcepub fn list_principals(&self) -> Vec<String>
pub fn list_principals(&self) -> Vec<String>
List all principals
Sourcepub fn update_password(&self, name: &str, new_password: &str) -> AuthResult<()>
pub fn update_password(&self, name: &str, new_password: &str) -> AuthResult<()>
Update principal password
Sourcepub fn add_role_to_principal(
&self,
principal_name: &str,
role_name: &str,
) -> AuthResult<()>
pub fn add_role_to_principal( &self, principal_name: &str, role_name: &str, ) -> AuthResult<()>
Add a role to a principal
Sourcepub fn remove_role_from_principal(
&self,
principal_name: &str,
role_name: &str,
) -> AuthResult<()>
pub fn remove_role_from_principal( &self, principal_name: &str, role_name: &str, ) -> AuthResult<()>
Remove a role from a principal
Sourcepub fn create_role(&self, role: Role) -> AuthResult<()>
pub fn create_role(&self, role: Role) -> AuthResult<()>
Create a custom role
Sourcepub fn delete_role(&self, name: &str) -> AuthResult<()>
pub fn delete_role(&self, name: &str) -> AuthResult<()>
Delete a custom role
Sourcepub fn list_roles(&self) -> Vec<String>
pub fn list_roles(&self) -> Vec<String>
List all roles
Sourcepub fn remove_acls(
&self,
principal: Option<&str>,
resource: Option<&ResourceType>,
)
pub fn remove_acls( &self, principal: Option<&str>, resource: Option<&ResourceType>, )
Remove ACL entries matching criteria
Sourcepub fn authenticate(
&self,
username: &str,
password: &str,
client_ip: &str,
) -> AuthResult<AuthSession>
pub fn authenticate( &self, username: &str, password: &str, client_ip: &str, ) -> AuthResult<AuthSession>
Authenticate a principal and create a session
Sourcepub fn get_session(&self, session_id: &str) -> Option<AuthSession>
pub fn get_session(&self, session_id: &str) -> Option<AuthSession>
Get an active session by ID
Sourcepub fn invalidate_session(&self, session_id: &str)
pub fn invalidate_session(&self, session_id: &str)
Invalidate a session (logout)
Sourcepub fn invalidate_all_sessions(&self, principal_name: &str)
pub fn invalidate_all_sessions(&self, principal_name: &str)
Invalidate all sessions for a principal
Sourcepub fn cleanup_expired_sessions(&self)
pub fn cleanup_expired_sessions(&self)
Clean up expired sessions
Sourcepub fn create_session(&self, principal: &Principal) -> AuthSession
pub fn create_session(&self, principal: &Principal) -> AuthSession
Create a session for a principal (used by SCRAM after successful auth)
Check if a session/principal has permission on a resource
Simple authorization check without session (for internal use)
Auto Trait Implementations§
impl !Freeze for AuthManager
impl !RefUnwindSafe for AuthManager
impl Send for AuthManager
impl Sync for AuthManager
impl Unpin for AuthManager
impl UnwindSafe for AuthManager
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