[−][src]Struct schemeguardian::AuthEngine
Struct structure
use redactedsecret::SecretString; use serde::{Serialize, Deserialize}; use schemeguardian::{ImmutableRole, Lease}; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct AuthEngine { identifier: SecretString, role: ImmutableRole, lease: Lease, random_key: SecretString, }
Example
use schemeguardian::{AuthEngine, ImmutableRole, Lease}; use redactedsecret::SecretString; use std::time::{SystemTime, Duration}; use tai64::{TAI64N}; AuthEngine::new() .identifier(SecretString::new("Foo".to_owned())) .role(ImmutableRole::Admin) .lease(Lease::DateExpiryTAI(TAI64N::from_system_time(&(SystemTime::now() + Duration::from_secs(2))))) .build();
Methods
impl AuthEngine
[src]
Usage
use schemeguardian::AuthEngine; AuthEngine::new();
pub fn new() -> Self
[src]
pub fn identifier(self, user: SecretString) -> Self
[src]
Add an identifier
Example
use schemeguardian::AuthEngine; use redactedsecret::SecretString; AuthEngine::new() .identifier(SecretString::new("Foo".to_owned()));
pub fn role(self, value: ImmutableRole) -> Self
[src]
Add a Role
Example
use schemeguardian::{AuthEngine, ImmutableRole}; AuthEngine::new() .role(ImmutableRole::Admin);
pub fn lease(self, lease: Lease) -> Self
[src]
Add a Lease
Example
use schemeguardian::{AuthEngine, Lease}; use std::time::{SystemTime, Duration}; use tai64::{TAI64N}; AuthEngine::new() .lease(Lease::DateExpiryTAI(TAI64N::from_system_time(&(SystemTime::now() + Duration::from_secs(2)))));
pub fn build(self) -> Self
[src]
Adds a random 64bit CSRNG phrase and builds the struct
Example
use schemeguardian::AuthEngine; AuthEngine::new() .build();
pub fn insert(self) -> Result<DbOps, SGError>
[src]
Inserts the secrets into the Key-Value Store
Example
use schemeguardian::AuthEngine; AuthEngine::new() .build() .insert();
pub fn show_random(self) -> Result<SecretString, SGError>
[src]
Shows the random 64bit CSRNG key
Example
use schemeguardian::AuthEngine; AuthEngine::new() .show_random();
pub fn show_role(self) -> Result<ImmutableRole, SGError>
[src]
Shows value for ImmutableRole
Example
use schemeguardian::AuthEngine; AuthEngine::new() .show_role();
pub fn authenticate(
&self,
user_random: SecretString
) -> Result<(AccessStatus, Payload), SGError>
[src]
&self,
user_random: SecretString
) -> Result<(AccessStatus, Payload), SGError>
Authenticate an existing token
Currently returns:
custom_codes::AccessStatus::Expired
for an secret that has reached end of life
custom_codes::AccessStatus::Granted
for a secret that is live and RAC is authenticated
custom_codes::AccessStatus::RejectedRAC
for a secret that is live but the RAC is not authentic
custom_codes::AccessStatus::Rejected
for a secret that cannot be authenticated
Example
use schemeguardian::AuthEngine; use redactedsecret::SecretString; use serde::{Serialize, Deserialize}; #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] enum Custom { ExecutiveBoard, } AuthEngine::new() .authenticate(SecretString::new("Foo".to_owned()));
Trait Implementations
impl Clone for AuthEngine
[src]
fn clone(&self) -> AuthEngine
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for AuthEngine
[src]
impl Serialize for AuthEngine
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for AuthEngine
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl Send for AuthEngine
impl Sync for AuthEngine
impl Unpin for AuthEngine
impl UnwindSafe for AuthEngine
impl RefUnwindSafe for AuthEngine
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,