pub fn new(
        enabled: bool,
        super_user_key: String,
        storage: &sled::Db,
    ) -> Result<Self> {
        let super_user_data = TokenData {
            token: super_user_key.clone(),
            allowed_indexes: None,
            permissions: permissions::SUPER_USER,
            created: Utc::now(),
            user: Some(String::from("CONFIG SUPER USER")),
            description: Some(String::from(
                "The super use as defined in the cli commands.",
            )),
        };

        let mut map = HashMap::new();
        if let Some(data) = storage.get(KEYSPACE)? {
            let tokens: Vec<TokenData> =
                bincode::options().with_big_endian().deserialize(&data)?;

            for token in tokens {
                map.insert(token.token.to_string(), Arc::new(token));
            }
        }

        map.insert(super_user_key, Arc::new(super_user_data));

        Ok(Self {
            auth_enabled: enabled,
            keys: Arc::new(ArcSwap::from_pointee(map)),
        })
    }
/// Creates a new manager being enabled/disabled with a given super user key.
///
/// If disabled the super use key can be an empty string.
///
/// The super user key is simply used as a default key to allow people to
/// access the control endpoints for the first time.
/// The super user key can be revoked.
Creates a new manager being enabled/disabled with a given super user key.
If disabled the super use key can be an empty string.

The super user key is simply used as a default key to allow people to
access the control endpoints for the first time.
The super user key can be revoked.
Creates a new manager being enabled / disabled with a given super user key . If disabled the super use key can be an empty string . The super user key is simply used as a default key to allow people to access the control endpoints for the first time . The super user key can be revoked .
pub fn new(
        enabled: bool,
        super_user_key: String,
        storage: &sled::Db,
    ) -> Result<Self> {
        let super_user_data = TokenData {
            token: super_user_key.clone(),
            allowed_indexes: None,
            permissions: permissions::SUPER_USER,
            created: Utc::now(),
            user: Some(String::from("CONFIG SUPER USER")),
            description: Some(String::from(
                "The super use as defined in the cli commands.",
            )),
        };
        let mut map = HashMap::new();
        if let Some(data) = storage.get(KEYSPACE)? {
            let tokens: Vec<TokenData> =
                bincode::options().with_big_endian().deserialize(&data)?;
            for token in tokens {
                map.insert(token.token.to_string(), Arc::new(token));
            }
        }
        map.insert(super_user_key, Arc::new(super_user_data));
        Ok(Self {
            auth_enabled: enabled,
            keys: Arc::new(ArcSwap::from_pointee(map)),
        })
    }
pub fn new ( enabled : bool , super_user_key : String , storage : & sled :: Db , ) -> Result < Self > { let super_user_data = TokenData { token : super_user_key . clone ( ) , allowed_indexes : None , permissions : permissions :: SUPER_USER , created : Utc :: now ( ) , user : Some ( String :: from ( " " ) ) , description : Some ( String :: from ( " " , ) ) , } ; let mut map = HashMap :: new ( ) ; if let Some ( data ) = storage . get ( KEYSPACE ) ? { let tokens : Vec < TokenData > = bincode :: options ( ) . with_big_endian ( ) . deserialize ( & data ) ? ; for token in tokens { map . insert ( token . token . to_string ( ) , Arc :: new ( token ) ) ; } } map . insert ( super_user_key , Arc :: new ( super_user_data ) ) ; Ok ( Self { auth_enabled : enabled , keys : Arc :: new ( ArcSwap :: from_pointee ( map ) ) , } ) }
Creates a new manager being enabled/disabled with a given super user key.
Creates a new manager being enabled / disabled with a given super user key .
enabled
bool
super_user_key
String
storage
&sled::Db
enabled
bool
super_user_key
String
storage
&sled::Db