mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-04 00:34:40 +01:00
bump dependencies
This commit is contained in:
parent
733af58e89
commit
fd4d6e5537
4 changed files with 136 additions and 72 deletions
118
Cargo.lock
generated
118
Cargo.lock
generated
|
@ -353,9 +353,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.4.0"
|
||||
version = "3.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
|
||||
checksum = "f07aa6688c702439a1be0307b6a94dffe1168569e45b9500c1372bc580740d59"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
|
@ -484,7 +484,7 @@ dependencies = [
|
|||
"hkdf",
|
||||
"hmac",
|
||||
"percent-encoding",
|
||||
"rand",
|
||||
"rand 0.7.3",
|
||||
"sha2",
|
||||
"time",
|
||||
"version_check",
|
||||
|
@ -613,15 +613,6 @@ version = "2.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "993a608597367c6377b258c25d7120740f00ed23a2252b729b1932dd7866f908"
|
||||
|
||||
[[package]]
|
||||
name = "dbus"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4a0c10ea61042b7555729ab0608727bbbb06ce709c11e6047cfa4e10f6d052d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deflate"
|
||||
version = "0.8.6"
|
||||
|
@ -1070,7 +1061,18 @@ checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
|
|||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasi 0.9.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"wasi 0.10.1+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1444,9 +1446,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "http-types"
|
||||
version = "2.9.0"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2ab8d0085fb82859c9adf050bd53992297ecdd03a665a230dfa50c8c964bf3d"
|
||||
checksum = "32613ebb139d1d430ef5783676f84abfa06fc5f2b4b5a25220cdeeff7e16ef5c"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-channel",
|
||||
|
@ -1455,8 +1457,8 @@ dependencies = [
|
|||
"cookie",
|
||||
"futures-lite",
|
||||
"infer",
|
||||
"pin-project-lite 0.1.11",
|
||||
"rand",
|
||||
"pin-project-lite 0.2.4",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_qs",
|
||||
|
@ -2266,11 +2268,23 @@ version = "0.7.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.1.16",
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
"rand_chacha 0.2.2",
|
||||
"rand_core 0.5.1",
|
||||
"rand_hc 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18519b42a40024d661e1714153e9ad0c3de27cd495760ceb09710920f1098b1e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha 0.3.0",
|
||||
"rand_core 0.6.1",
|
||||
"rand_hc 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2280,7 +2294,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
"rand_core 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.6.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2289,7 +2313,16 @@ version = "0.5.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.1.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5"
|
||||
dependencies = [
|
||||
"getrandom 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2298,7 +2331,16 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
"rand_core 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core 0.6.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2419,18 +2461,22 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
|||
|
||||
[[package]]
|
||||
name = "secret-service"
|
||||
version = "1.1.3"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d752040301c251d653aa740dec847e95767ce312cfc469bee85eb13cbf81d8a"
|
||||
checksum = "2400fb1bf2a87b303ada204946294f932ade4929477e9e2bf66d7b49a66656ec"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"block-modes",
|
||||
"dbus",
|
||||
"hkdf",
|
||||
"lazy_static",
|
||||
"num",
|
||||
"rand",
|
||||
"rand 0.8.2",
|
||||
"serde",
|
||||
"sha2",
|
||||
"zbus",
|
||||
"zbus_macros",
|
||||
"zvariant",
|
||||
"zvariant_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2688,9 +2734,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.58"
|
||||
version = "1.0.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5"
|
||||
checksum = "07cb8b1b4ebf86a89ee88cbd201b022b94138c623644d035185c84d3f41b7e66"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2743,11 +2789,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447"
|
||||
checksum = "301bdd13d23c49672926be451130892d274d3ba0b410c18e00daa7990ff38d99"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2982,6 +3028,12 @@ version = "0.9.0+wasi-snapshot-preview1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.69"
|
||||
|
|
|
@ -7,8 +7,8 @@ version = "0.1.0"
|
|||
adw = {package = "libadwaita", git = "https://gitlab.gnome.org/bilelmoussaoui/libadwaita-rs"}
|
||||
anyhow = "1.0"
|
||||
ashpd = {git = "https://github.com/bilelmoussaoui/ashpd", features = ["feature_gtk4"]}
|
||||
async-std = "1.8"
|
||||
data-encoding = "2.1"
|
||||
async-std = "1.9"
|
||||
data-encoding = "2.3"
|
||||
diesel = {version = "1.4", features = ["sqlite", "r2d2"]}
|
||||
diesel_migrations = {version = "1.4", features = ["sqlite"]}
|
||||
futures = "0.3"
|
||||
|
@ -26,7 +26,7 @@ pretty_env_logger = "0.4"
|
|||
qrcode = {version = "0.12", features = ["image"]}
|
||||
quick-xml = "0.20"
|
||||
ring = "0.16"
|
||||
secret-service = "1.1"
|
||||
secret-service = "2.0"
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
sha2 = "0.9"
|
||||
|
|
|
@ -1,20 +1,36 @@
|
|||
use crate::config;
|
||||
use secret_service::{Collection, EncryptionType, SecretService, SsError};
|
||||
use secret_service::{Collection, EncryptionType, Error, SecretService};
|
||||
use sha2::{Digest, Sha512};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct Keyring;
|
||||
|
||||
fn token_attributes(token_id: &str) -> HashMap<&str, &str> {
|
||||
let mut attributes = HashMap::new();
|
||||
attributes.insert("application", config::APP_ID);
|
||||
attributes.insert("type", "token");
|
||||
attributes.insert("token_id", &token_id);
|
||||
attributes
|
||||
}
|
||||
|
||||
fn password_attributes() -> HashMap<&'static str, &'static str> {
|
||||
let mut attributes = HashMap::new();
|
||||
attributes.insert("application", config::APP_ID);
|
||||
attributes.insert("type", "password");
|
||||
attributes
|
||||
}
|
||||
|
||||
impl Keyring {
|
||||
pub fn get_default_collection(ss: &SecretService) -> Result<Collection, SsError> {
|
||||
pub fn get_default_collection<'a>(ss: &'a SecretService<'a>) -> Result<Collection<'a>, Error> {
|
||||
let collection = match ss.get_default_collection() {
|
||||
Err(SsError::NoResult) => ss.create_collection("default", "default"),
|
||||
Err(Error::NoResult) => ss.create_collection("default", "default"),
|
||||
e => e,
|
||||
}?;
|
||||
|
||||
Ok(collection)
|
||||
}
|
||||
|
||||
pub fn ensure_unlocked() -> Result<(), SsError> {
|
||||
pub fn ensure_unlocked() -> Result<(), Error> {
|
||||
let ss = secret_service::SecretService::new(secret_service::EncryptionType::Dh)?;
|
||||
let collection = Keyring::get_default_collection(&ss)?;
|
||||
collection.ensure_unlocked()?;
|
||||
|
@ -22,63 +38,58 @@ impl Keyring {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn store(label: &str, token: &str) -> Result<String, SsError> {
|
||||
pub fn store(label: &str, token: &str) -> Result<String, Error> {
|
||||
let token = token.as_bytes();
|
||||
let ss = SecretService::new(EncryptionType::Dh)?;
|
||||
let col = Self::get_default_collection(&ss)?;
|
||||
|
||||
let token_id = hex::encode(Sha512::digest(token));
|
||||
let attributes = vec![
|
||||
("application", config::APP_ID),
|
||||
("type", "token"),
|
||||
("token_id", &token_id),
|
||||
];
|
||||
let attributes = token_attributes(&token_id);
|
||||
let base64_token = hex::encode(token);
|
||||
col.create_item(label, attributes, base64_token.as_bytes(), true, "plain")?;
|
||||
Ok(token_id)
|
||||
}
|
||||
|
||||
pub fn token(token_id: &str) -> Result<Option<String>, SsError> {
|
||||
pub fn token(token_id: &str) -> Result<Option<String>, Error> {
|
||||
let ss = SecretService::new(EncryptionType::Dh)?;
|
||||
let col = Self::get_default_collection(&ss)?;
|
||||
let items = col.search_items(vec![
|
||||
("type", "token"),
|
||||
("token_id", token_id),
|
||||
("application", config::APP_ID),
|
||||
])?;
|
||||
|
||||
let attributes = token_attributes(token_id);
|
||||
let items = col.search_items(attributes)?;
|
||||
Ok(match items.get(0) {
|
||||
Some(e) => Some(String::from_utf8(hex::decode(e.get_secret()?).unwrap()).unwrap()),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn remove_token(token_id: &str) -> Result<(), SsError> {
|
||||
pub fn remove_token(token_id: &str) -> Result<(), Error> {
|
||||
let ss = SecretService::new(EncryptionType::Dh)?;
|
||||
let col = Self::get_default_collection(&ss)?;
|
||||
let items = col.search_items(vec![
|
||||
("type", "token"),
|
||||
("token_id", token_id),
|
||||
("application", config::APP_ID),
|
||||
])?;
|
||||
|
||||
let attributes = token_attributes(token_id);
|
||||
let items = col.search_items(attributes)?;
|
||||
match items.get(0) {
|
||||
Some(e) => e.delete(),
|
||||
_ => Err(SsError::NoResult),
|
||||
_ => Err(Error::NoResult),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_set_password() -> Result<bool, SsError> {
|
||||
pub fn has_set_password() -> Result<bool, Error> {
|
||||
let ss = SecretService::new(EncryptionType::Dh)?;
|
||||
let col = Self::get_default_collection(&ss)?;
|
||||
match col.search_items(vec![("type", "password"), ("application", config::APP_ID)]) {
|
||||
|
||||
let attributes = password_attributes();
|
||||
match col.search_items(attributes) {
|
||||
Ok(items) => Ok(matches!(items.get(0), Some(_))),
|
||||
_ => Ok(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_password(password: &str) -> Result<(), SsError> {
|
||||
pub fn set_password(password: &str) -> Result<(), Error> {
|
||||
let ss = SecretService::new(EncryptionType::Dh)?;
|
||||
let col = Self::get_default_collection(&ss)?;
|
||||
let attributes = vec![("application", config::APP_ID), ("type", "password")];
|
||||
|
||||
let attributes = password_attributes();
|
||||
col.create_item(
|
||||
"Authenticator password",
|
||||
attributes,
|
||||
|
@ -89,23 +100,25 @@ impl Keyring {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn reset_password() -> Result<(), SsError> {
|
||||
pub fn reset_password() -> Result<(), Error> {
|
||||
let ss = SecretService::new(EncryptionType::Dh)?;
|
||||
let col = Self::get_default_collection(&ss)?;
|
||||
let items =
|
||||
col.search_items(vec![("type", "password"), ("application", config::APP_ID)])?;
|
||||
|
||||
let attributes = password_attributes();
|
||||
let items = col.search_items(attributes)?;
|
||||
|
||||
match items.get(0) {
|
||||
Some(i) => i.delete(),
|
||||
None => Err(SsError::NoResult),
|
||||
None => Err(Error::NoResult),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_current_password(password: &str) -> Result<bool, SsError> {
|
||||
pub fn is_current_password(password: &str) -> Result<bool, Error> {
|
||||
let ss = SecretService::new(EncryptionType::Dh)?;
|
||||
let col = Self::get_default_collection(&ss)?;
|
||||
let items =
|
||||
col.search_items(vec![("type", "password"), ("application", config::APP_ID)])?;
|
||||
|
||||
let attributes = password_attributes();
|
||||
let items = col.search_items(attributes)?;
|
||||
Ok(match items.get(0) {
|
||||
Some(i) => i.get_secret()? == password.as_bytes(),
|
||||
None => false,
|
||||
|
|
|
@ -60,9 +60,8 @@ pub(crate) fn steam(secret: &str) -> Result<String> {
|
|||
)?;
|
||||
let mut code = String::new();
|
||||
let total_chars = STEAM_CHARS.len() as u32;
|
||||
for i in 0..5 {
|
||||
for _ in 0..5 {
|
||||
let pos = token % total_chars;
|
||||
println!("{:#?}", pos);
|
||||
let charachter = STEAM_CHARS.chars().nth(pos as usize).unwrap();
|
||||
code.push(charachter);
|
||||
token = token / total_chars;
|
||||
|
|
Loading…
Add table
Reference in a new issue