Skip to main content

AuthManager

Struct AuthManager 

Source
pub struct AuthManager { /* private fields */ }
Expand description

The main authentication and authorization manager

Implementations§

Source§

impl AuthManager

Source

pub fn new(config: AuthConfig) -> Self

Create a new authentication manager

Source

pub fn new_default() -> Self

Create with default config

Source

pub fn with_auth_enabled() -> Self

Create an auth manager with authentication enabled

Source

pub fn create_principal( &self, name: &str, password: &str, principal_type: PrincipalType, roles: HashSet<String>, ) -> AuthResult<()>

Create a new principal (user or service account)

Source

pub fn delete_principal(&self, name: &str) -> AuthResult<()>

Delete a principal

Source

pub fn get_principal(&self, name: &str) -> Option<Principal>

Get a principal by name

Source

pub fn list_principals(&self) -> Vec<String>

List all principals

Source

pub fn update_password(&self, name: &str, new_password: &str) -> AuthResult<()>

Update principal password

Source

pub fn add_role_to_principal( &self, principal_name: &str, role_name: &str, ) -> AuthResult<()>

Add a role to a principal

Source

pub fn remove_role_from_principal( &self, principal_name: &str, role_name: &str, ) -> AuthResult<()>

Remove a role from a principal

Source

pub fn create_role(&self, role: Role) -> AuthResult<()>

Create a custom role

Source

pub fn delete_role(&self, name: &str) -> AuthResult<()>

Delete a custom role

Source

pub fn get_role(&self, name: &str) -> Option<Role>

Get a role by name

Source

pub fn list_roles(&self) -> Vec<String>

List all roles

Source

pub fn add_acl(&self, entry: AclEntry)

Add an ACL entry

Source

pub fn remove_acls( &self, principal: Option<&str>, resource: Option<&ResourceType>, )

Remove ACL entries matching criteria

Source

pub fn list_acls(&self) -> Vec<AclEntry>

List ACL entries

Source

pub fn authenticate( &self, username: &str, password: &str, client_ip: &str, ) -> AuthResult<AuthSession>

Authenticate a principal and create a session

Source

pub fn get_session(&self, session_id: &str) -> Option<AuthSession>

Get an active session by ID

Source

pub fn invalidate_session(&self, session_id: &str)

Invalidate a session (logout)

Source

pub fn invalidate_all_sessions(&self, principal_name: &str)

Invalidate all sessions for a principal

Source

pub fn cleanup_expired_sessions(&self)

Clean up expired sessions

Source

pub fn create_session(&self, principal: &Principal) -> AuthSession

Create a session for a principal (used by SCRAM after successful auth)

Source

pub fn authorize( &self, session: &AuthSession, resource: &ResourceType, permission: Permission, client_ip: &str, ) -> AuthResult<()>

Check if a session/principal has permission on a resource

Source

pub fn authorize_anonymous( &self, resource: &ResourceType, permission: Permission, ) -> AuthResult<()>

Simple authorization check without session (for internal use)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more