pub struct AuthenticationService {
AppState: Arc<ApplicationState>,
Sessions: Arc<RwLock<HashMap<String, AuthSession>>>,
Credentials: Arc<Mutex<CredentialsStore>>,
CryptoKeys: Arc<Mutex<CryptoKeys>>,
AeadAlgo: &'static Algorithm,
}Expand description
Authentication service implementation
Fields§
§AppState: Arc<ApplicationState>Application state
Sessions: Arc<RwLock<HashMap<String, AuthSession>>>Active sessions
Credentials: Arc<Mutex<CredentialsStore>>Credentials storage
CryptoKeys: Arc<Mutex<CryptoKeys>>Cryptographic keys
AeadAlgo: &'static AlgorithmAEAD algorithm for encryption/decryption
Implementations§
Source§impl AuthenticationService
impl AuthenticationService
Sourcepub async fn new(AppState: Arc<ApplicationState>) -> Result<Self>
pub async fn new(AppState: Arc<ApplicationState>) -> Result<Self>
Create a new authentication service
Sourcepub async fn AuthenticateUser(
&self,
Username: String,
Password: String,
Provider: String,
) -> Result<String>
pub async fn AuthenticateUser( &self, Username: String, Password: String, Provider: String, ) -> Result<String>
Authenticate a user
Sourceasync fn ValidateCredentials(
&self,
Username: &str,
Password: &str,
Provider: &str,
) -> Result<UserCredentials>
async fn ValidateCredentials( &self, Username: &str, Password: &str, Provider: &str, ) -> Result<UserCredentials>
Validate user credentials
Sourceasync fn GenerateSessionToken(
&self,
Username: &str,
Provider: &str,
) -> Result<String>
async fn GenerateSessionToken( &self, Username: &str, Provider: &str, ) -> Result<String>
Generate a session token
Sourceasync fn UpdateCredentialsUsage(
&self,
Username: &str,
Provider: &str,
) -> Result<()>
async fn UpdateCredentialsUsage( &self, Username: &str, Provider: &str, ) -> Result<()>
Update credentials usage timestamp
Sourceasync fn EncryptPassword(&self, Password: &str) -> Result<String>
async fn EncryptPassword(&self, Password: &str) -> Result<String>
Encrypt password
Sourceasync fn DecryptPassword(&self, EncryptedPassword: &str) -> Result<String>
async fn DecryptPassword(&self, EncryptedPassword: &str) -> Result<String>
Decrypt password
Sourceasync fn LoadCredentialsStore(FilePath: &Path) -> Result<CredentialsStore>
async fn LoadCredentialsStore(FilePath: &Path) -> Result<CredentialsStore>
Load credentials store from file
Sourceasync fn SaveCredentialsStore(&self, Store: &CredentialsStore) -> Result<()>
async fn SaveCredentialsStore(&self, Store: &CredentialsStore) -> Result<()>
Save credentials store to file
Sourcefn GenerateCryptoKeys() -> Result<CryptoKeys>
fn GenerateCryptoKeys() -> Result<CryptoKeys>
Generate cryptographic keys
Sourcepub async fn StartBackgroundTasks(&self) -> Result<JoinHandle<()>>
pub async fn StartBackgroundTasks(&self) -> Result<JoinHandle<()>>
Start background tasks
Sourceasync fn BackgroundTask(&self)
async fn BackgroundTask(&self)
Background task for session cleanup
Sourceasync fn CleanupExpiredSessions(&self)
async fn CleanupExpiredSessions(&self)
Clean up expired sessions
Sourceasync fn SaveCredentialsPeriodically(&self) -> Result<()>
async fn SaveCredentialsPeriodically(&self) -> Result<()>
Save credentials periodically
Sourcepub async fn StopBackgroundTasks(&self)
pub async fn StopBackgroundTasks(&self)
Stop background tasks
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuthenticationService
impl !RefUnwindSafe for AuthenticationService
impl Send for AuthenticationService
impl Sync for AuthenticationService
impl Unpin for AuthenticationService
impl !UnwindSafe for AuthenticationService
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].