mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-04 00:34:40 +01:00
tools/fetcher: Decode tokens
This commit is contained in:
parent
42011356d5
commit
a06721730f
3 changed files with 19 additions and 7 deletions
1
tools/keyring-fetcher/Cargo.lock
generated
1
tools/keyring-fetcher/Cargo.lock
generated
|
@ -597,6 +597,7 @@ name = "keyring-fetch"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"hex",
|
||||
"oo7",
|
||||
]
|
||||
|
||||
|
|
|
@ -7,4 +7,5 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
oo7 = {version = "0.1.0-alpha.5", features = ["tracing", "unstable", "async-std"]}
|
||||
async-std = "1.11.0"
|
||||
async-std = "1.11.0"
|
||||
hex = "0.4"
|
||||
|
|
|
@ -26,15 +26,25 @@ async fn main() -> oo7::Result<()> {
|
|||
let secret = items[0].secret().await?;
|
||||
let keyring = oo7::portal::Keyring::load(keyring_path, &secret).await?;
|
||||
|
||||
let keyring_items = keyring.items().await?;
|
||||
let keyring_items = keyring
|
||||
.search_items(HashMap::from([("type", "token")]))
|
||||
.await?;
|
||||
for item in keyring_items.iter() {
|
||||
let attributes = item.attributes();
|
||||
let secret = item.secret();
|
||||
println!(
|
||||
"Found a secret: \nAttributes: {:#?}\nSecret: {:#?}",
|
||||
attributes,
|
||||
String::from_utf8_lossy(&secret)
|
||||
);
|
||||
if let Ok(decoded_secret) = hex::decode(secret.clone()) {
|
||||
println!(
|
||||
"Found a secret: \nAttributes: {:#?}\nSecret: {:#?}",
|
||||
attributes,
|
||||
String::from_utf8_lossy(&decoded_secret)
|
||||
);
|
||||
} else {
|
||||
println!(
|
||||
"ERROR!! Failed to decode secret for \n Attributes {:#?} \n {:#?}",
|
||||
attributes,
|
||||
String::from_utf8_lossy(&secret)
|
||||
);
|
||||
}
|
||||
println!("################################################");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue