Struct AuthManager

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

Authentication manager that handles users and roles

Implementations§

Source§

impl AuthManager

Source

pub fn new() -> Self

Source

pub async fn add_user(&self, user: User) -> PgWireResult<()>

Add a new user to the system

Source

pub async fn add_role(&self, role: Role) -> PgWireResult<()>

Add a new role to the system

Source

pub async fn authenticate( &self, username: &str, password: &str, ) -> PgWireResult<bool>

Authenticate a user with username and password

Source

pub async fn get_user(&self, username: &str) -> Option<User>

Get user information

Source

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

Get role information

Source

pub async fn user_has_role(&self, username: &str, role_name: &str) -> bool

Check if user has a specific role

Source

pub async fn list_users(&self) -> Vec<String>

List all users (for administrative purposes)

Source

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

List all roles (for administrative purposes)

Source

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

Source

pub async fn revoke_permission( &self, role_name: &str, permission: Permission, resource: ResourceType, ) -> PgWireResult<()>

Revoke permission from a role

Source

pub async fn check_permission( &self, username: &str, permission: Permission, resource: ResourceType, ) -> bool

Check if a user has a specific permission on a resource

Source

pub async fn add_role_inheritance( &self, child_role: &str, parent_role: &str, ) -> PgWireResult<()>

Add role inheritance

Source

pub async fn remove_role_inheritance( &self, child_role: &str, parent_role: &str, ) -> PgWireResult<()>

Remove role inheritance

Source

pub async fn create_role(&self, config: RoleConfig) -> PgWireResult<()>

Create a new role with specific capabilities

Source

pub async fn create_predefined_roles(&self) -> PgWireResult<()>

Create common predefined roles

Trait Implementations§

Source§

impl Debug for AuthManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AuthManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<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, 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> 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> ErasedDestructor for T
where T: 'static,