mirror of
https://gitlab.com/hagrid-keyserver/hagrid.git
synced 2023-02-13 20:55:02 -05:00
rename state_dir to token_dir
This commit is contained in:
parent
120480cdc5
commit
a724a96406
3 changed files with 12 additions and 12 deletions
|
@ -4,7 +4,7 @@ port = 8080
|
|||
template_dir = "dist/templates"
|
||||
assets_dir = "dist/assets"
|
||||
keys_dir = "dist/keys"
|
||||
state_dir = "dist/hagrid_state"
|
||||
token_dir = "dist/tokens"
|
||||
tmp_dir = "dist/tmp"
|
||||
|
||||
[development]
|
||||
|
|
|
@ -7,18 +7,18 @@ use std::str;
|
|||
use Result;
|
||||
|
||||
pub struct StatefulTokens {
|
||||
state_dir: PathBuf,
|
||||
token_dir: PathBuf,
|
||||
}
|
||||
|
||||
impl StatefulTokens {
|
||||
pub fn new(state_dir: impl Into<PathBuf>) -> Result<Self> {
|
||||
let state_dir = state_dir.into();
|
||||
create_dir_all(&state_dir)?;
|
||||
pub fn new(token_dir: impl Into<PathBuf>) -> Result<Self> {
|
||||
let token_dir = token_dir.into();
|
||||
create_dir_all(&token_dir)?;
|
||||
|
||||
info!("Opened stateful token store");
|
||||
info!("state_dir: '{}'", state_dir.display());
|
||||
info!("token_dir: '{}'", token_dir.display());
|
||||
|
||||
Ok(StatefulTokens { state_dir })
|
||||
Ok(StatefulTokens { token_dir })
|
||||
}
|
||||
|
||||
pub fn new_token(&self, token_type: &str, payload: &[u8]) -> Result<String> {
|
||||
|
@ -29,7 +29,7 @@ impl StatefulTokens {
|
|||
// samples from [a-zA-Z0-9]
|
||||
// 43 chars ~ 256 bit
|
||||
let name: String = rng.sample_iter(&Alphanumeric).take(43).collect();
|
||||
let dir = self.state_dir.join(token_type);
|
||||
let dir = self.token_dir.join(token_type);
|
||||
create_dir_all(&dir)?;
|
||||
|
||||
let mut fd = File::create(dir.join(&name))?;
|
||||
|
@ -39,7 +39,7 @@ impl StatefulTokens {
|
|||
}
|
||||
|
||||
pub fn pop_token(&self, token_type: &str, token: &str) -> Result<String> {
|
||||
let path = self.state_dir.join(token_type).join(token);
|
||||
let path = self.token_dir.join(token_type).join(token);
|
||||
let buf = {
|
||||
let mut fd = File::open(&path)?;
|
||||
let mut buf = Vec::default();
|
||||
|
|
|
@ -416,8 +416,8 @@ fn configure_hagrid_state(config: &Config) -> Result<HagridState> {
|
|||
}
|
||||
|
||||
fn configure_stateful_token_service(config: &Config) -> Result<database::StatefulTokens> {
|
||||
let state_dir: PathBuf = config.get_str("state_dir")?.into();
|
||||
database::StatefulTokens::new(state_dir)
|
||||
let token_dir: PathBuf = config.get_str("token_dir")?.into();
|
||||
database::StatefulTokens::new(token_dir)
|
||||
}
|
||||
|
||||
fn configure_stateless_token_service(config: &Config) -> Result<tokens::Service> {
|
||||
|
@ -502,7 +502,7 @@ pub mod tests {
|
|||
.to_str().unwrap())
|
||||
.extra("keys_dir", base_dir.join("keys").to_str().unwrap())
|
||||
.extra("tmp_dir", base_dir.join("tmp").to_str().unwrap())
|
||||
.extra("state_dir", base_dir.join("state").to_str().unwrap())
|
||||
.extra("token_dir", base_dir.join("tokens").to_str().unwrap())
|
||||
.extra("base-URI", BASE_URI)
|
||||
.extra("from", "from")
|
||||
.extra("token_secret", "hagrid")
|
||||
|
|
Loading…
Reference in a new issue