[−][src]Struct websession::Authenticator
The Authenticator is the main interface to Websession. It is responsible for tracking session IDs, and the users associated with the ID, if any. It also provides pass through support to the BackingStore for user management.
Methods
impl Authenticator
[src]
pub fn new(
backing_store: Box<dyn BackingStore + Send + Sync>,
expiration: Duration,
policy: SessionPolicy
) -> Authenticator
[src]
backing_store: Box<dyn BackingStore + Send + Sync>,
expiration: Duration,
policy: SessionPolicy
) -> Authenticator
Create a new Authenticator. expiration
is how long a session
should live w/o activity. Activity resets the clock on a
session.
pub fn verify(&self, user: &str, credentials: &str) -> Result<bool, AuthError>
[src]
Verify that the provided credentials
apply to the given
user
. Does not change any signatures associated with the
user.
pub fn login(
&self,
user: &str,
credentials: &str,
signature: &ConnectionSignature
) -> Result<(), AuthError>
[src]
&self,
user: &str,
credentials: &str,
signature: &ConnectionSignature
) -> Result<(), AuthError>
Verify that the provided credentials
apply to the given
user
. If they do, associate the user with the given
signature
. Credentials are as provided by the user. Plain
text in the case of passwords.
pub fn logout(&self, signature: &ConnectionSignature)
[src]
Remove any association of a user to the given signature
, and remove
the session.
pub fn get_user(
&self,
signature: &ConnectionSignature
) -> Result<Option<String>, AuthError>
[src]
&self,
signature: &ConnectionSignature
) -> Result<Option<String>, AuthError>
Get the user
associated with the session, if any.
pub fn encrypt_credentials(&self, plain_cred: &str) -> Result<String, AuthError>
[src]
Encrypt the credentials as expected by the backing store.
pub fn update_credentials(
&self,
user: &str,
enc_creds: &str
) -> Result<(), AuthError>
[src]
&self,
user: &str,
enc_creds: &str
) -> Result<(), AuthError>
Update the user's credentials, e.g. password. Credentials should already be encrypted/hashed, or the user will not be able to log in (and plain text will be stored in the backing store).
pub fn update_credentials_plain(
&self,
user: &str,
plain_creds: &str
) -> Result<(), AuthError>
[src]
&self,
user: &str,
plain_creds: &str
) -> Result<(), AuthError>
Update the user's credentials, e.g. password. Credentials should be in plain text, which will then be encrypted according to the BackingStore's implementation.
pub fn lock_user(&self, user: &str) -> Result<(), AuthError>
[src]
Disable a user's ability to login. The password will not be changed, but all login attempts will fail.
pub fn is_locked(&self, user: &str) -> Result<bool, AuthError>
[src]
Check if the user's account is locked.
pub fn unlock(&self, user: &str) -> Result<(), AuthError>
[src]
Re-enable the user's account. The old password will remain valid.
pub fn create_preencrypted(
&self,
user: &str,
enc_creds: &str
) -> Result<(), AuthError>
[src]
&self,
user: &str,
enc_creds: &str
) -> Result<(), AuthError>
Create a new user with the given credentials. Credentials should already be encrypted/hashed, or the user will not be able to log in (and plain text will be stored in the backing store).
pub fn create_plain(
&self,
user: &str,
plain_creds: &str
) -> Result<(), AuthError>
[src]
&self,
user: &str,
plain_creds: &str
) -> Result<(), AuthError>
Create a new user with the given credentials. Credentials should be in plain text, which will then be encrypted according to the BackingStore's implementation.
pub fn delete(&self, user: &str) -> Result<(), AuthError>
[src]
Delete the given user. Any stored credentials will be deleted too, and will need to be provided again if the user is later re-created.
pub fn run(
&self,
signature: ConnectionSignature
) -> Result<ConnectionSignature, AuthError>
[src]
&self,
signature: ConnectionSignature
) -> Result<ConnectionSignature, AuthError>
This is the main driver. It returns a signature that contains the current value for the cookie, or an error if something went wrong. The returned signature may be different from the one provided.
pub fn users(&self) -> Result<Vec<String>, AuthError>
[src]
Return a Vec of usernames.
pub fn users_iter(&self) -> Result<IntoIter<String>, AuthError>
[src]
Return an iterator over users.
pub fn check_user(&self, user: &str) -> Result<bool, AuthError>
[src]
Identify whether or not the user already exists in the backing store.
May return an AuthError````, in particular,
AuthError::Locked`, which
means that the user exists but the account is locked.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Authenticator
impl Send for Authenticator
impl Sync for Authenticator
impl Unpin for Authenticator
impl !UnwindSafe for Authenticator
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,