[][src]Struct schemeguardian::AuthEngine

pub struct AuthEngine { /* fields omitted */ }

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]

Initialize a new AuthEngine

Example

use schemeguardian::AuthEngine;

AuthEngine::new();
     

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]

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]

impl Debug for AuthEngine[src]

impl Serialize for AuthEngine[src]

impl<'de> Deserialize<'de> for AuthEngine[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,