Compare commits
No commits in common. "25f082ee6f00f70d67c24e3bba416f48f0b91521" and "a810842e6813be1e8e0080510cda591fc8cbeb17" have entirely different histories.
25f082ee6f
...
a810842e68
5 changed files with 28 additions and 17 deletions
18
Cargo.lock
generated
18
Cargo.lock
generated
|
@ -218,6 +218,7 @@ name = "audrey"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-channel",
|
"async-channel",
|
||||||
|
"base16ct",
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
@ -227,6 +228,7 @@ dependencies = [
|
||||||
"glib-build-tools",
|
"glib-build-tools",
|
||||||
"gtk4",
|
"gtk4",
|
||||||
"libadwaita",
|
"libadwaita",
|
||||||
|
"md-5",
|
||||||
"oo7",
|
"oo7",
|
||||||
"rand",
|
"rand",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
@ -259,6 +261,12 @@ dependencies = [
|
||||||
"windows-targets",
|
"windows-targets",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "base16ct"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.22.1"
|
version = "0.22.1"
|
||||||
|
@ -1526,6 +1534,16 @@ checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"digest",
|
"digest",
|
||||||
|
"md5-asm",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "md5-asm"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d19b8ee7fc7d812058d3b708c7f719efd0713d53854648e4223c6fcae709e2df"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -6,12 +6,14 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
|
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
|
||||||
async-channel = "2.3.1"
|
async-channel = "2.3.1"
|
||||||
|
base16ct = { version = "0.2.0", features = ["std"] }
|
||||||
bytes = "1.8.0"
|
bytes = "1.8.0"
|
||||||
chrono = { version = "0.4.38", features = ["serde"] }
|
chrono = { version = "0.4.38", features = ["serde"] }
|
||||||
event-listener = "5.3.1"
|
event-listener = "5.3.1"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
gettext-rs = { version = "0.7.2", features = ["gettext-system"] }
|
gettext-rs = { version = "0.7.2", features = ["gettext-system"] }
|
||||||
gtk = { version = "0.9.2", package = "gtk4", features = ["v4_16"] }
|
gtk = { version = "0.9.2", package = "gtk4", features = ["v4_16"] }
|
||||||
|
md-5 = { version = "0.10.6", features = ["asm"] }
|
||||||
oo7 = "0.3.3"
|
oo7 = "0.3.3"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
reqwest = { version = "0.12.9", default-features = false, features = [
|
reqwest = { version = "0.12.9", default-features = false, features = [
|
||||||
|
|
|
@ -3,8 +3,8 @@ pub mod schema;
|
||||||
mod album_list;
|
mod album_list;
|
||||||
pub use album_list::AlbumListType;
|
pub use album_list::AlbumListType;
|
||||||
|
|
||||||
use adw::glib;
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
use md5::Digest;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use tracing::{event, Level};
|
use tracing::{event, Level};
|
||||||
|
|
||||||
|
@ -75,10 +75,11 @@ impl Client {
|
||||||
// subsonic docs say to generate a salt per request, but that's completely unnecessary
|
// subsonic docs say to generate a salt per request, but that's completely unnecessary
|
||||||
let salt_hex = random_salt(SALT_BYTES);
|
let salt_hex = random_salt(SALT_BYTES);
|
||||||
|
|
||||||
let mut hasher = glib::Checksum::new(glib::ChecksumType::Md5).unwrap();
|
let mut hasher = md5::Md5::new();
|
||||||
hasher.update(password);
|
hasher.update(password);
|
||||||
hasher.update(salt_hex.as_bytes());
|
hasher.update(salt_hex.as_bytes());
|
||||||
let token_hex = hasher.string().unwrap();
|
let token = hasher.finalize();
|
||||||
|
let token_hex = base16ct::lower::encode_string(&token);
|
||||||
|
|
||||||
Self::with_token(url, username, &token_hex, &salt_hex)
|
Self::with_token(url, username, &token_hex, &salt_hex)
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,6 @@ mod imp {
|
||||||
|
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
use gtk::glib;
|
use gtk::glib;
|
||||||
use tracing::{event, Level};
|
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
pub struct Setup(ObjectSubclass<imp::Setup>)
|
pub struct Setup(ObjectSubclass<imp::Setup>)
|
||||||
|
@ -149,8 +148,6 @@ impl Setup {
|
||||||
|
|
||||||
// TODO remove unwraps, make sure authn_can_edit is set back to true
|
// TODO remove unwraps, make sure authn_can_edit is set back to true
|
||||||
let keyring = oo7::Keyring::new().await.unwrap();
|
let keyring = oo7::Keyring::new().await.unwrap();
|
||||||
// make sure the keyring is unlocked
|
|
||||||
keyring.unlock().await.unwrap();
|
|
||||||
let attributes = vec![("xdg:schema", crate::APP_ID)];
|
let attributes = vec![("xdg:schema", crate::APP_ID)];
|
||||||
let items = keyring.search_items(&attributes).await.unwrap();
|
let items = keyring.search_items(&attributes).await.unwrap();
|
||||||
|
|
||||||
|
@ -159,19 +156,12 @@ impl Setup {
|
||||||
// TODO: onboarding
|
// TODO: onboarding
|
||||||
self.set_authn_can_edit(true);
|
self.set_authn_can_edit(true);
|
||||||
self.set_authn_can_validate(true);
|
self.set_authn_can_validate(true);
|
||||||
|
|
||||||
event!(Level::DEBUG, "TODO: setup onboarding");
|
|
||||||
} else {
|
} else {
|
||||||
let item = &items[0];
|
let item = &items[0];
|
||||||
let attributes = item.attributes().await.unwrap();
|
let attributes = item.attributes().await.unwrap();
|
||||||
|
|
||||||
let server_url = &attributes["server-url"];
|
self.set_server_url(attributes["server-url"].clone());
|
||||||
let username = &attributes["username"];
|
self.set_username(attributes["username"].clone());
|
||||||
|
|
||||||
event!(Level::DEBUG, "logging in as {} at {}", username, server_url);
|
|
||||||
|
|
||||||
self.set_server_url(server_url.clone());
|
|
||||||
self.set_username(username.clone());
|
|
||||||
// strip non-utf8 elements from the pw, i guess
|
// strip non-utf8 elements from the pw, i guess
|
||||||
self.set_password(String::from_utf8_lossy(&item.secret().await.unwrap()));
|
self.set_password(String::from_utf8_lossy(&item.secret().await.unwrap()));
|
||||||
|
|
||||||
|
|
|
@ -613,7 +613,7 @@ mod imp {
|
||||||
};
|
};
|
||||||
|
|
||||||
match perform.await {
|
match perform.await {
|
||||||
Ok(()) => {}
|
Ok(()) => {},
|
||||||
Err(err) => event!(Level::ERROR, "could not refresh album list: {err}"),
|
Err(err) => event!(Level::ERROR, "could not refresh album list: {err}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue