Skip to content

Commit

Permalink
Miscellaneous stuff (#599)
Browse files Browse the repository at this point in the history
* up

* flake.lock: Update

Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/fd86b78f5f35f712c72147427b1eb81a9bd55d0b?narHash=sha256-lxTce2XE6mfJH8Zk6yBbqsbu9/jpwdymbSH5cCbiVOA%3D' (2024-10-07)
  → 'github:ipetkov/crane/f876e3d905b922502f031aeec1a84490122254b7?narHash=sha256-fROVjMcKRoGHofDm8dY3uDUtCMwUICh/KjBFQnuBzfg%3D' (2024-10-12)
• Updated input 'devenv':
    'github:cachix/devenv/e7a0bc559f5a66aaa42f5028db6162c4dd4587eb?narHash=sha256-YtknslVeAXyK3zq6AoazydZrC8tisiZzvHsvZJAqMRk%3D' (2024-10-09)
  → 'github:cachix/devenv/7afa57b19353149c5814f1da66d23993dea732a6?narHash=sha256-gA31aflrrsSCukNnxnBgCfrfGClXxc00ZE%2BR%2B7r9W6c%3D' (2024-10-17)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/c31898adf5a8ed202ce5bea9f347b1c6871f32d1?narHash=sha256-yumd4fBc/hi8a9QgA9IT8vlQuLZ2oqhkJXHPKxH/tRw%3D' (2024-10-06)
  → 'github:nixos/nixpkgs/a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c?narHash=sha256-nsNdSldaAyu6PE3YUA%2BYQLqUDJh%2BgRbBooMMekZJwvI%3D' (2024-10-14)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/e310b9bd71fa6c6a9fec0a8cf5af43ce798a0ad6?narHash=sha256-cd0cXB85B3kGpm%2BiumP9xCnqFErspXL9Z/2X59kQ6c4%3D' (2024-10-09)
  → 'github:oxalica/rust-overlay/16fb78d443c1970dda9a0bbb93070c9d8598a925?narHash=sha256-uNyi5vQrzaLkt4jj6ZEOs4%2B4UqOAwP6jFG2s7LIDwIk%3D' (2024-10-17)

* use scc instead of moka in oidc logic

* revert to moka, add tests
  • Loading branch information
aumetra authored Oct 17, 2024
1 parent 411683c commit 3cbe5bf
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 48 deletions.
41 changes: 21 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/kitsune-activitypub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sha2 = { version = "0.10.8", features = ["asm"] }

[dev-dependencies]
http-body-util = "0.1.2"
hyper = "1.4.1"
hyper = "1.5.0"
kitsune-config = { workspace = true }
kitsune-test = { workspace = true }
kitsune-webfinger = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/kitsune-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ kitsune-language = { workspace = true }
kitsune-type = { workspace = true }
num-derive = "0.4.2"
num-traits = "0.2.19"
rustls = { version = "0.23.14", default-features = false, features = [
rustls = { version = "0.23.15", default-features = false, features = [
"logging",
"ring",
"std",
Expand Down
2 changes: 1 addition & 1 deletion crates/kitsune-derive/impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license.workspace = true
proc-macro = true

[dependencies]
proc-macro2 = "1.0.87"
proc-macro2 = "1.0.88"
quote = "1.0.37"
syn = { version = "2.0.79", features = ["full"] }

Expand Down
2 changes: 1 addition & 1 deletion crates/kitsune-http-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ futures-util = { version = "0.3.31", default-features = false, features = [
http-body = "1.0.1"
http-body-util = "0.1.2"
http-signatures = { workspace = true }
hyper = "1.4.1"
hyper = "1.5.0"
hyper-util = { version = "0.1.9", features = [
"client-legacy",
"http1",
Expand Down
2 changes: 1 addition & 1 deletion crates/kitsune-observability/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license.workspace = true
async-trait = "0.1.83"
eyre = "0.6.12"
http-body-util = "0.1.2"
hyper = { version = "1.4.1", default-features = false }
hyper = { version = "1.5.0", default-features = false }
kitsune-config = { workspace = true }
kitsune-core = { workspace = true }
kitsune-http-client = { workspace = true }
Expand Down
6 changes: 5 additions & 1 deletion crates/kitsune-oidc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ kitsune-config = { workspace = true }
kitsune-derive = { workspace = true }
kitsune-error = { workspace = true }
kitsune-http-client = { workspace = true }
moka = { workspace = true }
moka = { workspace = true, features = ["sync"] }
oauth2 = { version = "5.0.0-rc.1", default-features = false }
openidconnect = { version = "4.0.0-rc.1", default-features = false, features = [
# Accept these two, per specification invalid, cases to increase compatibility
"accept-rfc3339-timestamps",
"accept-string-booleans",
"timing-resistant-secret-traits",
] }
serde = { version = "1.0.210", features = ["derive"] }
sonic-rs = { workspace = true }
speedy-uuid = { workspace = true }
url = "2.5.2"

[dev-dependencies]
tokio = { version = "1.40.0", features = ["macros", "rt"] }

[lints]
workspace = true
4 changes: 2 additions & 2 deletions crates/kitsune-oidc/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ pub use self::store::{AnyStore, Store};

pub mod store;

#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
pub struct OAuth2LoginState {
pub application_id: Uuid,
pub scope: String,
pub state: Option<String>,
}

#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct LoginState {
pub nonce: Nonce,
pub pkce_verifier: PkceCodeVerifier,
Expand Down
49 changes: 49 additions & 0 deletions crates/kitsune-oidc/src/state/store/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,52 @@ impl Store for InMemory {
Ok(())
}
}

#[cfg(test)]
mod test {
use super::InMemory;
use crate::state::{LoginState, OAuth2LoginState, Store};
use oauth2::PkceCodeVerifier;
use openidconnect::Nonce;
use speedy_uuid::Uuid;

#[tokio::test]
async fn basic_ops() {
let val = LoginState {
nonce: Nonce::new_random(),
pkce_verifier: PkceCodeVerifier::new("test".into()),
oauth2: OAuth2LoginState {
application_id: Uuid::now_v7(),
scope: "owo".into(),
state: None,
},
};

let in_memory = InMemory::new(10);
in_memory.set("uwu", val.clone()).await.unwrap();
let got_val = in_memory.get_and_remove("uwu").await.unwrap();
assert_eq!(got_val, val);
}

#[tokio::test]
async fn limits_size() {
let val = LoginState {
nonce: Nonce::new_random(),
pkce_verifier: PkceCodeVerifier::new("test".into()),
oauth2: OAuth2LoginState {
application_id: Uuid::now_v7(),
scope: "owo".into(),
state: None,
},
};

let in_memory = InMemory::new(2);
in_memory.set("owo", val.clone()).await.unwrap();
in_memory.set("uwu", val.clone()).await.unwrap();
in_memory.set("ùwú", val.clone()).await.unwrap();

in_memory.inner.run_pending_tasks();

assert_eq!(in_memory.inner.entry_count(), 2);
}
}
2 changes: 1 addition & 1 deletion crates/kitsune-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ zxcvbn = { version = "3.1.0", default-features = false }
[dev-dependencies]
hex-simd = "0.8.0"
http-body-util = "0.1.2"
hyper = "1.4.1"
hyper = "1.5.0"
kitsune-activitypub = { workspace = true }
kitsune-config = { workspace = true }
kitsune-federation-filter = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/kitsune-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rusty-s3 = { version = "0.5.0", default-features = false }
tokio = { workspace = true, features = ["time"] }
triomphe = { workspace = true }
url = "2.5.2"
uuid = { version = "1.10.0", features = ["fast-rng", "v4"] }
uuid = { version = "1.11.0", features = ["fast-rng", "v4"] }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion crates/kitsune-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license.workspace = true
bubble-bath = "0.2.0"
iso8601-timestamp = { workspace = true }
kitsune-type = { workspace = true }
pulldown-cmark = { version = "0.12.1", default-features = false, features = [
pulldown-cmark = { version = "0.12.2", default-features = false, features = [
"html",
"simd",
] }
Expand Down
2 changes: 1 addition & 1 deletion crates/kitsune-webfinger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ urlencoding = "2.1.3"

[dev-dependencies]
http-body-util = "0.1.2"
hyper = "1.4.1"
hyper = "1.5.0"
pretty_assertions = "1.4.1"
sonic-rs = { workspace = true }
tokio = { workspace = true, features = ["macros"] }
Expand Down
24 changes: 12 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/fast-cjson/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ olpc-cjson = "0.1.4"
proptest = { version = "1.5.0", default-features = false, features = ["std"] }
proptest-derive = "0.5.0"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
serde_json = "1.0.129"

[lints]
workspace = true
4 changes: 2 additions & 2 deletions lib/masto-id-convert/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ atoi_radix10 = "0.0.1"
nanorand = { version = "0.7.0", default-features = false, features = [
"wyrand",
] }
uuid = { version = "1.10.0", default-features = false }
uuid = { version = "1.11.0", default-features = false }

[features]
default = ["std"]
Expand All @@ -23,7 +23,7 @@ std = []
[dev-dependencies]
divan = "0.1.14"
time = "0.3.36"
uuid = { version = "1.10.0", features = ["v7"] }
uuid = { version = "1.11.0", features = ["v7"] }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion lib/speedy-uuid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ diesel = { version = "2.2.4", default-features = false, features = [
fred = { version = "9.2.1", default-features = false, optional = true }
serde = { version = "1.0.210", optional = true }
thiserror = "1.0.64"
uuid = { version = "1.10.0", features = ["fast-rng", "v7"] }
uuid = { version = "1.11.0", features = ["fast-rng", "v7"] }
uuid-simd = { version = "0.8.0", features = ["uuid"] }

[dev-dependencies]
Expand Down

0 comments on commit 3cbe5bf

Please sign in to comment.