From be218c89cc573f70ab3ccc17928911a6573e0630 Mon Sep 17 00:00:00 2001 From: Iris System Date: Mon, 18 Aug 2025 21:57:26 +1200 Subject: [PATCH] fixup! working just like it was before :) --- Cargo.lock | 1 + Cargo.toml | 2 +- crates/api/src/main.rs | 7 ++++--- crates/api/src/middleware/auth.rs | 4 +--- crates/libpk/src/_config.rs | 5 ----- crates/models/Cargo.toml | 5 ++--- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aec30906..58ff0cf9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2616,6 +2616,7 @@ dependencies = [ "serde", "serde_json", "sqlx", + "tracing", "uuid", ] diff --git a/Cargo.toml b/Cargo.toml index d4a2299b..cd65b342 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ reqwest = { version = "0.12.7" , default-features = false, features = ["rustls-t sentry = { version = "0.36.0", default-features = false, features = ["backtrace", "contexts", "panic", "debug-images", "reqwest", "rustls"] } # replace native-tls with rustls serde = { version = "1.0.196", features = ["derive"] } serde_json = "1.0.117" -sqlx = { version = "0.8.2", features = ["runtime-tokio", "postgres", "time", "macros", "uuid"] } +sqlx = { version = "0.8.2", features = ["runtime-tokio", "postgres", "time", "chrono", "macros", "uuid"] } tokio = { version = "1.36.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3.16", features = ["env-filter", "json"] } diff --git a/crates/api/src/main.rs b/crates/api/src/main.rs index 1dca7ade..ffc75542 100644 --- a/crates/api/src/main.rs +++ b/crates/api/src/main.rs @@ -13,6 +13,7 @@ use hyper_util::{ client::legacy::{connect::HttpConnector, Client}, rt::TokioExecutor, }; + use jsonwebtoken::{DecodingKey, EncodingKey}; use tracing::{error, info}; use pk_macros::api_endpoint; @@ -136,9 +137,9 @@ fn router(ctx: ApiContext) -> Router { .route("/internal/apikey/user", post(endpoints::internal::create_api_key_user)) - .route("/v2/systems/:system_id/oembed.json", get(rproxy)) - .route("/v2/members/:member_id/oembed.json", get(rproxy)) - .route("/v2/groups/:group_id/oembed.json", get(rproxy)) + .route("/v2/systems/{system_id}/oembed.json", get(rproxy)) + .route("/v2/members/{member_id}/oembed.json", get(rproxy)) + .route("/v2/groups/{group_id}/oembed.json", get(rproxy)) .layer(middleware::ratelimit::ratelimiter(ctx.clone(), middleware::ratelimit::do_request_ratelimited)) diff --git a/crates/api/src/middleware/auth.rs b/crates/api/src/middleware/auth.rs index 46435ff7..2a1c757d 100644 --- a/crates/api/src/middleware/auth.rs +++ b/crates/api/src/middleware/auth.rs @@ -142,11 +142,9 @@ pub async fn auth(State(ctx): State, mut req: Request, next: Next) - .await .expect("failed to query apitoken in postgres") { + authed_system_id = Some(token.system); authed_api_key_id = Some(tid); access_level = apikey_can_access(&token, req.method().to_string(), endpoint.clone()); - if access_level != AccessLevel::None { - authed_system_id = Some(token.system); - } } else if let Some(system_id) = match libpk::db::repository::legacy_token_auth(&ctx.db, system_auth_header).await { diff --git a/crates/libpk/src/_config.rs b/crates/libpk/src/_config.rs index a15d95f9..d8843058 100644 --- a/crates/libpk/src/_config.rs +++ b/crates/libpk/src/_config.rs @@ -60,13 +60,8 @@ pub struct ApiConfig { pub remote_url: String, - #[serde(default)] - pub temp_token2: Option, - pub token_privatekey: String, pub token_publickey: String, - - pub internal_request_secret: String, } #[derive(Deserialize, Clone, Debug)] diff --git a/crates/models/Cargo.toml b/crates/models/Cargo.toml index 1766a7b3..e0a7c9fd 100644 --- a/crates/models/Cargo.toml +++ b/crates/models/Cargo.toml @@ -11,7 +11,6 @@ jsonwebtoken = { workspace = true } sea-query = "0.32.1" serde = { workspace = true } serde_json = { workspace = true, features = ["preserve_order"] } -# in theory we want to default-features = false for sqlx -# but cargo doesn't seem to support this -sqlx = { workspace = true, features = ["chrono"] } +sqlx = { workspace = true } uuid = { workspace = true } +tracing = { workspace = true }