pub struct VbrAuthService { /* private fields */ }Expand description
Authentication service for VBR
Implementations§
Source§impl VbrAuthService
impl VbrAuthService
Sourcepub fn new(jwt_secret: String, token_expiration_secs: u64) -> Self
pub fn new(jwt_secret: String, token_expiration_secs: u64) -> Self
Create a new authentication service
Sourcepub async fn create_default_user(
&self,
username: String,
password: String,
email: String,
) -> Result<VirtualUser>
pub async fn create_default_user( &self, username: String, password: String, email: String, ) -> Result<VirtualUser>
Create a default user (for demo/testing)
Sourcepub async fn authenticate(
&self,
username: &str,
password: &str,
) -> Result<VirtualUser>
pub async fn authenticate( &self, username: &str, password: &str, ) -> Result<VirtualUser>
Authenticate a user
Sourcepub fn generate_token(&self, user: &VirtualUser) -> Result<String>
pub fn generate_token(&self, user: &VirtualUser) -> Result<String>
Generate JWT token for a user
Automatically uses virtual clock if time travel is enabled, otherwise uses real time.
Sourcepub fn validate_token(&self, token: &str) -> Result<VirtualUser>
pub fn validate_token(&self, token: &str) -> Result<VirtualUser>
Validate JWT token
Sourcepub async fn get_user(&self, username: &str) -> Option<VirtualUser>
pub async fn get_user(&self, username: &str) -> Option<VirtualUser>
Get user by username
Sourcepub async fn list_users(&self) -> Vec<VirtualUser>
pub async fn list_users(&self) -> Vec<VirtualUser>
List all users
Auto Trait Implementations§
impl Freeze for VbrAuthService
impl !RefUnwindSafe for VbrAuthService
impl Send for VbrAuthService
impl Sync for VbrAuthService
impl Unpin for VbrAuthService
impl !UnwindSafe for VbrAuthService
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> 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> 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