pub struct AuthManager { /* private fields */ }Expand description
Authentication and authorization manager.
Implementations§
Source§impl AuthManager
impl AuthManager
Sourcepub fn new(keys: Vec<ApiKeyEntry>) -> Self
pub fn new(keys: Vec<ApiKeyEntry>) -> Self
Create a new auth manager with authentication enabled.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if authentication is enabled.
Sourcepub fn authenticate(&self, api_key: &str) -> Option<Role>
pub fn authenticate(&self, api_key: &str) -> Option<Role>
Authenticate an API key. Returns the role if valid.
Check if a role is authorized for a given operation.
Sourcepub fn audit(&self, api_key: &str, role: Role, operation: &str, allowed: bool)
pub fn audit(&self, api_key: &str, role: Role, operation: &str, allowed: bool)
Record an operation in the audit log.
Sourcepub fn recent_audit(&self, count: usize) -> Vec<AuditEntry>
pub fn recent_audit(&self, count: usize) -> Vec<AuditEntry>
Get recent audit log entries.
Sourcepub fn add_key(&self, entry: ApiKeyEntry)
pub fn add_key(&self, entry: ApiKeyEntry)
Add a new API key.
Sourcepub fn revoke_key(&self, api_key: &str) -> bool
pub fn revoke_key(&self, api_key: &str) -> bool
Revoke (deactivate) an API key.
Sourcepub fn operation_name(request_json: &str) -> &str
pub fn operation_name(request_json: &str) -> &str
Get the operation name from a request type string.
Auto Trait Implementations§
impl !Freeze for AuthManager
impl RefUnwindSafe for AuthManager
impl Send for AuthManager
impl Sync for AuthManager
impl Unpin for AuthManager
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request