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 Debug for AuthManager
impl Debug for AuthManager
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<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> 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