Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Sukhachev <[email protected]>
  • Loading branch information
alexsdsr committed Jan 30, 2024
1 parent 9943264 commit 00d839a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
11 changes: 2 additions & 9 deletions generate/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ fn generate_and_check(
let strategy =
ClaimsForSelectiveDisclosureStrategy::Custom(sd_claims_jsonpaths.iter().map(String::as_str).collect());

dbg!(&strategy);

let jwk: Option<Jwk> = if specs.key_binding.unwrap_or(false) {
let jwk: Jwk = serde_yaml::from_value(settings.key_settings.holder_key.clone()).unwrap();
Some(jwk)
Expand Down Expand Up @@ -253,17 +251,12 @@ fn load_salts(path: &PathBuf) -> Result<()> {
.map_err(|e| Error::from_msg(ErrorKind::IOError, e.to_string()))?;
let salts: Vec<String> = serde_json::from_str(&json_data)?;


dbg!(&salts);

{
let mut map = SALTS.lock().unwrap();
let mut s = SALTS.lock().unwrap();

for salt in salts.iter() {
map.push_back(salt.clone());
s.push_back(salt.clone());
}

dbg!(&map);
}
}

Expand Down
17 changes: 4 additions & 13 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{collections::VecDeque, sync::Mutex};

#[cfg(feature = "mock_salts")]
lazy_static! {
pub static ref SALTS: Mutex<VecDeque<String>> = Mutex::new(VecDeque::with_capacity(100));
pub static ref SALTS: Mutex<VecDeque<String>> = Mutex::new(VecDeque::new());
}

pub(crate) fn base64_hash(data: &[u8]) -> String {
Expand All @@ -43,19 +43,10 @@ pub(crate) fn generate_salt(_key_for_predefined_salt: Option<String>) -> String
base64url_encode(&buf)
}

#[cfg(feature = "mock_salts")]
pub(crate) fn generate_salt_mock(_key_for_predefined_salt: Option<String>) -> String {

#[cfg(feature = "mock_salts")]
{
let mut salts = SALTS.lock().unwrap();

if let Some(salt) = salts.pop_front() {
//FIXME better mock approach
return salt.clone()
}

panic!("salts is empty");
}
let mut salts = SALTS.lock().unwrap();
return salts.pop_front().expect("SALTS is empty");
}

pub(crate) fn jwt_payload_decode(b64data: &str) -> Result<serde_json::Map<String, Value>> {
Expand Down

0 comments on commit 00d839a

Please sign in to comment.