Skip to main content

AuthManager

Struct AuthManager 

Source
pub struct AuthManager<S, A, const SESSION_LEN: usize = DEFAULT_SESSION_LEN, const HASH_LEN: usize = DEFAULT_HASH_LEN, const PEPPER_LEN: usize = DEFAULT_PEPPER_LEN, const SALT_LEN: usize = DEFAULT_SALT_LEN>
where S: KVTrait<[u8; SESSION_LEN], SessionValue<SESSION_LEN>> + Send + Sync, A: KVTrait<str, AccountValue<SALT_LEN, HASH_LEN, SESSION_LEN>> + Send + Sync,
{ pub sessions: S, pub accounts: A, pub session_timeout: Duration, pub account_timeout: Duration, pub password_hasher: Argon2<'static>, pub pepper: [u8; PEPPER_LEN], }
Expand description

認証マネージャー

Fields§

§sessions: S§accounts: A§session_timeout: Duration§account_timeout: Duration§password_hasher: Argon2<'static>§pepper: [u8; PEPPER_LEN]

Implementations§

Source§

impl<S, A, const SESSION_LEN: usize, const HASH_LEN: usize, const PEPPER_LEN: usize, const SALT_LEN: usize> AuthManager<S, A, SESSION_LEN, HASH_LEN, PEPPER_LEN, SALT_LEN>
where S: KVTrait<[u8; SESSION_LEN], SessionValue<SESSION_LEN>> + Send + Sync, A: KVTrait<str, AccountValue<SALT_LEN, HASH_LEN, SESSION_LEN>> + Send + Sync,

Source

pub fn new( sessions: S, accounts: A, session_timeout: Duration, account_timeout: Duration, hash_config: HashConfig<PEPPER_LEN>, ) -> Self

Source

pub fn create_session(&self) -> [u8; SESSION_LEN]

新しいセッションを追加

Source

pub fn delete_session(&self, session_id: &[u8; SESSION_LEN]) -> bool

セッションを削除

Source

pub fn get_session( &self, session_id: &[u8; SESSION_LEN], ) -> Option<SessionValue<SESSION_LEN>>

セッションを取得

Source

pub fn add_account(&self, username: &str, password: &str)

新しいアカウントを追加

Source

pub fn delete_account(&self, username: &str) -> bool

アカウントを削除

Source

pub fn get_account( &self, username: &str, ) -> Option<AccountValue<SALT_LEN, HASH_LEN, SESSION_LEN>>

アカウントを取得

Source

pub fn check_and_gc_session( &self, session_id: &[u8; SESSION_LEN], ) -> Option<SessionValue<SESSION_LEN>>

セッションを検査して、期限切れなら削除

Source

pub fn auth_login( &self, session_id: &[u8; SESSION_LEN], username: &str, password: &str, ) -> bool

ログイン処理

Source

pub fn auth_logout( &self, session_id: &[u8; SESSION_LEN], username: &str, ) -> bool

ログアウト処理

セッションとアカウントをリンク

セッションとアカウントのリンクを解除

Auto Trait Implementations§

§

impl<S, A, const SESSION_LEN: usize, const HASH_LEN: usize, const PEPPER_LEN: usize, const SALT_LEN: usize> Freeze for AuthManager<S, A, SESSION_LEN, HASH_LEN, PEPPER_LEN, SALT_LEN>
where S: Freeze, A: Freeze,

§

impl<S, A, const SESSION_LEN: usize, const HASH_LEN: usize, const PEPPER_LEN: usize, const SALT_LEN: usize> RefUnwindSafe for AuthManager<S, A, SESSION_LEN, HASH_LEN, PEPPER_LEN, SALT_LEN>

§

impl<S, A, const SESSION_LEN: usize, const HASH_LEN: usize, const PEPPER_LEN: usize, const SALT_LEN: usize> Send for AuthManager<S, A, SESSION_LEN, HASH_LEN, PEPPER_LEN, SALT_LEN>

§

impl<S, A, const SESSION_LEN: usize, const HASH_LEN: usize, const PEPPER_LEN: usize, const SALT_LEN: usize> Sync for AuthManager<S, A, SESSION_LEN, HASH_LEN, PEPPER_LEN, SALT_LEN>

§

impl<S, A, const SESSION_LEN: usize, const HASH_LEN: usize, const PEPPER_LEN: usize, const SALT_LEN: usize> Unpin for AuthManager<S, A, SESSION_LEN, HASH_LEN, PEPPER_LEN, SALT_LEN>
where S: Unpin, A: Unpin,

§

impl<S, A, const SESSION_LEN: usize, const HASH_LEN: usize, const PEPPER_LEN: usize, const SALT_LEN: usize> UnsafeUnpin for AuthManager<S, A, SESSION_LEN, HASH_LEN, PEPPER_LEN, SALT_LEN>
where S: UnsafeUnpin, A: UnsafeUnpin,

§

impl<S, A, const SESSION_LEN: usize, const HASH_LEN: usize, const PEPPER_LEN: usize, const SALT_LEN: usize> UnwindSafe for AuthManager<S, A, SESSION_LEN, HASH_LEN, PEPPER_LEN, SALT_LEN>
where S: UnwindSafe, A: UnwindSafe,

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> 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.