pub struct AuthManager { /* private fields */ }Expand description
Authentication manager that handles users and roles
Implementations§
Source§impl AuthManager
impl AuthManager
pub fn new() -> Self
Sourcepub async fn add_user(&self, user: User) -> PgWireResult<()>
pub async fn add_user(&self, user: User) -> PgWireResult<()>
Add a new user to the system
Sourcepub async fn add_role(&self, role: Role) -> PgWireResult<()>
pub async fn add_role(&self, role: Role) -> PgWireResult<()>
Add a new role to the system
Sourcepub async fn authenticate(
&self,
username: &str,
password: &str,
) -> PgWireResult<bool>
pub async fn authenticate( &self, username: &str, password: &str, ) -> PgWireResult<bool>
Authenticate a user with username and password
Sourcepub async fn user_has_role(&self, username: &str, role_name: &str) -> bool
pub async fn user_has_role(&self, username: &str, role_name: &str) -> bool
Check if user has a specific role
Sourcepub async fn list_users(&self) -> Vec<String>
pub async fn list_users(&self) -> Vec<String>
List all users (for administrative purposes)
Sourcepub async fn list_roles(&self) -> Vec<String>
pub async fn list_roles(&self) -> Vec<String>
List all roles (for administrative purposes)
Sourcepub async fn grant_permission(
&self,
role_name: &str,
permission: Permission,
resource: ResourceType,
granted_by: &str,
with_grant_option: bool,
) -> PgWireResult<()>
pub async fn grant_permission( &self, role_name: &str, permission: Permission, resource: ResourceType, granted_by: &str, with_grant_option: bool, ) -> PgWireResult<()>
Grant permission to a role
Sourcepub async fn revoke_permission(
&self,
role_name: &str,
permission: Permission,
resource: ResourceType,
) -> PgWireResult<()>
pub async fn revoke_permission( &self, role_name: &str, permission: Permission, resource: ResourceType, ) -> PgWireResult<()>
Revoke permission from a role
Sourcepub async fn check_permission(
&self,
username: &str,
permission: Permission,
resource: ResourceType,
) -> bool
pub async fn check_permission( &self, username: &str, permission: Permission, resource: ResourceType, ) -> bool
Check if a user has a specific permission on a resource
Sourcepub async fn add_role_inheritance(
&self,
child_role: &str,
parent_role: &str,
) -> PgWireResult<()>
pub async fn add_role_inheritance( &self, child_role: &str, parent_role: &str, ) -> PgWireResult<()>
Add role inheritance
Sourcepub async fn remove_role_inheritance(
&self,
child_role: &str,
parent_role: &str,
) -> PgWireResult<()>
pub async fn remove_role_inheritance( &self, child_role: &str, parent_role: &str, ) -> PgWireResult<()>
Remove role inheritance
Sourcepub async fn create_role(&self, config: RoleConfig) -> PgWireResult<()>
pub async fn create_role(&self, config: RoleConfig) -> PgWireResult<()>
Create a new role with specific capabilities
Sourcepub async fn create_predefined_roles(&self) -> PgWireResult<()>
pub async fn create_predefined_roles(&self) -> PgWireResult<()>
Create common predefined roles
Trait Implementations§
Source§impl Clone for AuthManager
impl Clone for AuthManager
Source§fn clone(&self) -> AuthManager
fn clone(&self) -> AuthManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AuthManager
impl Debug for AuthManager
Source§impl Default for AuthManager
impl Default for AuthManager
Source§impl PgCatalogContextProvider for AuthManager
impl PgCatalogContextProvider for AuthManager
fn roles<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn role<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Role>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
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<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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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