From 86b61daeacf4f2837e51e79cb054df3a9323aafd Mon Sep 17 00:00:00 2001 From: aumetra Date: Fri, 29 Nov 2024 03:19:34 +0100 Subject: [PATCH] switch out askama --- Cargo.lock | 27 +++++- Cargo.toml | 1 + crates/kitsune-activitypub/Cargo.toml | 48 +++++------ crates/kitsune-cache/Cargo.toml | 10 +-- crates/kitsune-captcha/Cargo.toml | 6 +- crates/kitsune-core/Cargo.toml | 6 +- crates/kitsune-db/Cargo.toml | 20 ++--- crates/kitsune-derive/Cargo.toml | 2 +- crates/kitsune-email/Cargo.toml | 18 ++-- crates/kitsune-embed/Cargo.toml | 16 ++-- crates/kitsune-error/Cargo.toml | 4 +- crates/kitsune-federation-filter/Cargo.toml | 8 +- crates/kitsune-federation/Cargo.toml | 26 +++--- crates/kitsune-http-client/Cargo.toml | 14 ++-- crates/kitsune-jobs/Cargo.toml | 16 ++-- crates/kitsune-language/Cargo.toml | 6 +- crates/kitsune-mastodon/Cargo.toml | 26 +++--- crates/kitsune-observability/Cargo.toml | 6 +- crates/kitsune-oidc/Cargo.toml | 14 ++-- crates/kitsune-s3/Cargo.toml | 6 +- crates/kitsune-search/Cargo.toml | 20 ++--- crates/kitsune-service/Cargo.toml | 66 +++++++-------- crates/kitsune-storage/Cargo.toml | 6 +- crates/kitsune-test/Cargo.toml | 12 +-- crates/kitsune-type/Cargo.toml | 4 +- crates/kitsune-url/Cargo.toml | 4 +- crates/kitsune-util/Cargo.toml | 6 +- crates/kitsune-wasm-mrf/Cargo.toml | 16 ++-- crates/kitsune-webfinger/Cargo.toml | 18 ++-- kitsune-cli/Cargo.toml | 16 ++-- kitsune-job-runner/Cargo.toml | 34 ++++---- kitsune/Cargo.toml | 92 ++++++++++----------- kitsune/src/http/extractor/json.rs | 2 +- kitsune/src/lib.rs | 1 + kitsune/src/oauth2/mod.rs | 26 +++--- kitsune/src/oauth2/solicitor.rs | 28 ++++--- kitsune/src/template.rs | 38 +++++++++ lib/athena/Cargo.toml | 8 +- lib/cursiv/Cargo.toml | 2 +- lib/fast-cjson/Cargo.toml | 2 +- lib/geomjeungja/Cargo.toml | 8 +- lib/http-signatures-cli/Cargo.toml | 4 +- lib/http-signatures/Cargo.toml | 4 +- lib/mrf-manifest/Cargo.toml | 2 +- lib/mrf-tool/Cargo.toml | 6 +- lib/tower-x-clacks-overhead/Cargo.toml | 4 +- xtask/Cargo.toml | 2 +- 47 files changed, 390 insertions(+), 321 deletions(-) create mode 100644 kitsune/src/template.rs diff --git a/Cargo.lock b/Cargo.lock index 14ed68ac0..7c0a4821e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3312,8 +3312,6 @@ name = "kitsune" version = "0.0.1-pre.6" dependencies = [ "argon2", - "askama", - "askama_axum", "async-graphql", "async-graphql-axum", "async-trait", @@ -3368,9 +3366,11 @@ dependencies = [ "mimalloc", "mime", "mime_guess", + "minijinja", "oxide-auth", "oxide-auth-async", "oxide-auth-axum", + "parking_lot", "rust-embed", "scoped-futures", "serde", @@ -4335,6 +4335,12 @@ dependencies = [ "rustix", ] +[[package]] +name = "memo-map" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d1115007560874e373613744c6fba374c17688327a71c1476d1a5954cc857b" + [[package]] name = "miette" version = "7.4.0" @@ -4412,6 +4418,17 @@ dependencies = [ "unicase", ] +[[package]] +name = "minijinja" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c37e1b517d1dcd0e51dc36c4567b9d5a29262b3ec8da6cb5d35e27a8fb529b5" +dependencies = [ + "memo-map", + "self_cell", + "serde", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -6016,6 +6033,12 @@ dependencies = [ "thin-slice", ] +[[package]] +name = "self_cell" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a" + [[package]] name = "semver" version = "1.0.23" diff --git a/Cargo.toml b/Cargo.toml index 07c61fb82..45f510625 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,6 +116,7 @@ hickory-resolver = { version = "0.25.0-alpha.4", default-features = false, featu ] } iso8601-timestamp = "0.3.1" itertools = { version = "0.13.0", default-features = false } +minijinja = { version = "2.5.0", features = ["loader"] } moka = { version = "=0.12.7", features = ["sync"] } simdutf8 = { version = "0.1.5", features = ["aarch64_neon"] } sonic-rs = "=0.3.14" diff --git a/crates/kitsune-activitypub/Cargo.toml b/crates/kitsune-activitypub/Cargo.toml index ae4306bb1..5dcd9c979 100644 --- a/crates/kitsune-activitypub/Cargo.toml +++ b/crates/kitsune-activitypub/Cargo.toml @@ -8,35 +8,35 @@ license.workspace = true [dependencies] async-trait = "0.1.83" base64-simd = "0.8.0" -diesel = { workspace = true } -diesel-async = { workspace = true } +diesel.workspace = true +diesel-async.workspace = true futures-util = "0.3.31" headers = "0.4.0" http = "1.1.0" -iso8601-timestamp = { workspace = true } -kitsune-cache = { workspace = true } -kitsune-config = { workspace = true } -kitsune-core = { workspace = true } -kitsune-db = { workspace = true } -kitsune-embed = { workspace = true } -kitsune-error = { workspace = true } -kitsune-federation-filter = { workspace = true } -kitsune-http-client = { workspace = true } -kitsune-language = { workspace = true } -kitsune-search = { workspace = true } -kitsune-service = { workspace = true } -kitsune-type = { workspace = true } -kitsune-url = { workspace = true } -kitsune-util = { workspace = true } -kitsune-wasm-mrf = { workspace = true } +iso8601-timestamp.workspace = true +kitsune-cache.workspace = true +kitsune-config.workspace = true +kitsune-core.workspace = true +kitsune-db.workspace = true +kitsune-embed.workspace = true +kitsune-error.workspace = true +kitsune-federation-filter.workspace = true +kitsune-http-client.workspace = true +kitsune-language.workspace = true +kitsune-search.workspace = true +kitsune-service.workspace = true +kitsune-type.workspace = true +kitsune-url.workspace = true +kitsune-util.workspace = true +kitsune-wasm-mrf.workspace = true mime = "0.3.17" mime_guess = { version = "2.0.5", default-features = false } serde = "1.0.215" sha2 = "0.10.8" -sonic-rs = { workspace = true } -speedy-uuid = { workspace = true } +sonic-rs.workspace = true +speedy-uuid.workspace = true tracing = "0.1.41" -triomphe = { workspace = true } +triomphe.workspace = true typed-builder = "0.20.0" url = "2.5.4" @@ -46,9 +46,9 @@ sha2 = { version = "0.10.8", features = ["asm"] } [dev-dependencies] http-body-util = "0.1.2" hyper = "1.5.1" -kitsune-config = { workspace = true } -kitsune-test = { workspace = true } -kitsune-webfinger = { workspace = true } +kitsune-config.workspace = true +kitsune-test.workspace = true +kitsune-webfinger.workspace = true pretty_assertions = "1.4.1" tokio = { workspace = true, features = ["macros"] } tower = { version = "0.5.1", default-features = false, features = ["util"] } diff --git a/crates/kitsune-cache/Cargo.toml b/crates/kitsune-cache/Cargo.toml index 8d5931aae..a96f1ce3a 100644 --- a/crates/kitsune-cache/Cargo.toml +++ b/crates/kitsune-cache/Cargo.toml @@ -7,13 +7,13 @@ license.workspace = true [dependencies] enum_dispatch = "0.3.13" -fred = { workspace = true } -kitsune-error = { workspace = true } -moka = { workspace = true } +fred.workspace = true +kitsune-error.workspace = true +moka.workspace = true serde = "1.0.215" -sonic-rs = { workspace = true } +sonic-rs.workspace = true tracing = "0.1.41" -triomphe = { workspace = true } +triomphe.workspace = true typed-builder = "0.20.0" [dev-dependencies] diff --git a/crates/kitsune-captcha/Cargo.toml b/crates/kitsune-captcha/Cargo.toml index 1f17ffef6..3d603c71a 100644 --- a/crates/kitsune-captcha/Cargo.toml +++ b/crates/kitsune-captcha/Cargo.toml @@ -8,11 +8,11 @@ license.workspace = true [dependencies] enum_dispatch = "0.3.13" http = "1.1.0" -kitsune-error = { workspace = true } -kitsune-http-client = { workspace = true } +kitsune-error.workspace = true +kitsune-http-client.workspace = true serde = { version = "1.0.215", features = ["derive"] } serde_urlencoded = "0.7.1" -sonic-rs = { workspace = true } +sonic-rs.workspace = true strum = { version = "0.26.3", features = ["derive"] } typed-builder = "0.20.0" diff --git a/crates/kitsune-core/Cargo.toml b/crates/kitsune-core/Cargo.toml index c6a283b91..ccafe8349 100644 --- a/crates/kitsune-core/Cargo.toml +++ b/crates/kitsune-core/Cargo.toml @@ -9,11 +9,11 @@ license.workspace = true async-trait = "0.1.83" const_format = "0.2.33" git-version = "0.3.9" -kitsune-db = { workspace = true } -kitsune-error = { workspace = true } +kitsune-db.workspace = true +kitsune-error.workspace = true paste = "1.0.15" serde = { version = "1.0.215", features = ["derive"] } -triomphe = { workspace = true } +triomphe.workspace = true typed-builder = "0.20.0" unsize = "1.1.0" diff --git a/crates/kitsune-db/Cargo.toml b/crates/kitsune-db/Cargo.toml index 2df876fba..18b7ffd25 100644 --- a/crates/kitsune-db/Cargo.toml +++ b/crates/kitsune-db/Cargo.toml @@ -8,18 +8,18 @@ build = "build.rs" [dependencies] blowocking = { workspace = true, features = ["io"] } -diesel = { workspace = true } -diesel-async = { workspace = true } -diesel_full_text_search = { workspace = true } +diesel.workspace = true +diesel-async.workspace = true +diesel_full_text_search.workspace = true diesel_migrations = "2.2.0" futures-util = { version = "0.3.31", default-features = false, features = [ "alloc", ] } iso8601-timestamp = { workspace = true, features = ["diesel-pg"] } -kitsune-config = { workspace = true } -kitsune-error = { workspace = true } -kitsune-language = { workspace = true } -kitsune-type = { workspace = true } +kitsune-config.workspace = true +kitsune-error.workspace = true +kitsune-language.workspace = true +kitsune-type.workspace = true num-derive = "0.4.2" num-traits = "0.2.19" rustls = { version = "0.23.19", default-features = false, features = [ @@ -30,18 +30,18 @@ rustls = { version = "0.23.19", default-features = false, features = [ ] } rustls-native-certs = "0.8.1" serde = { version = "1.0.215", features = ["derive"] } -sonic-rs = { workspace = true } +sonic-rs.workspace = true speedy-uuid = { workspace = true, features = ["diesel"] } tokio = { workspace = true, features = ["rt"] } tokio-postgres = "0.7.12" tokio-postgres-rustls = "0.13.0" tracing = "0.1.41" tracing-log = "0.2.0" -trials = { workspace = true } +trials.workspace = true typed-builder = "0.20.0" [dev-dependencies] -kitsune-test = { workspace = true } +kitsune-test.workspace = true tokio = { workspace = true, features = ["macros"] } [lints] diff --git a/crates/kitsune-derive/Cargo.toml b/crates/kitsune-derive/Cargo.toml index 2c9a5a1ec..7be3dac34 100644 --- a/crates/kitsune-derive/Cargo.toml +++ b/crates/kitsune-derive/Cargo.toml @@ -7,7 +7,7 @@ license.workspace = true [dependencies] kitsune-derive-impl = { path = "impl" } -triomphe = { workspace = true } +triomphe.workspace = true typed-builder = "0.20.0" [lints] diff --git a/crates/kitsune-email/Cargo.toml b/crates/kitsune-email/Cargo.toml index d627d5f8f..f869c89ef 100644 --- a/crates/kitsune-email/Cargo.toml +++ b/crates/kitsune-email/Cargo.toml @@ -9,14 +9,14 @@ license.workspace = true ignored = ["askama_axum"] # See reason below. [dependencies] -askama = { workspace = true } +askama.workspace = true askama_axum = "0.4.0" # Damn it, cargo. Because "kitsune" uses "askama" with the axum feature, we have to have the crate available here as well.. -diesel = { workspace = true } -diesel-async = { workspace = true } -kitsune-db = { workspace = true } -kitsune-derive = { workspace = true } -kitsune-error = { workspace = true } -kitsune-url = { workspace = true } +diesel.workspace = true +diesel-async.workspace = true +kitsune-db.workspace = true +kitsune-derive.workspace = true +kitsune-error.workspace = true +kitsune-url.workspace = true lettre = { version = "0.11.10", default-features = false, features = [ "builder", "hostname", @@ -30,8 +30,8 @@ mrml = { version = "4.0.1", default-features = false, features = [ "parse", "render", ] } -speedy-uuid = { workspace = true } -triomphe = { workspace = true } +speedy-uuid.workspace = true +triomphe.workspace = true typed-builder = "0.20.0" [lints] diff --git a/crates/kitsune-embed/Cargo.toml b/crates/kitsune-embed/Cargo.toml index c65fc7550..ea161a403 100644 --- a/crates/kitsune-embed/Cargo.toml +++ b/crates/kitsune-embed/Cargo.toml @@ -6,16 +6,16 @@ version.workspace = true license.workspace = true [dependencies] -diesel = { workspace = true } -diesel-async = { workspace = true } +diesel.workspace = true +diesel-async.workspace = true http = "1.1.0" -iso8601-timestamp = { workspace = true } -kitsune-db = { workspace = true } -kitsune-derive = { workspace = true } -kitsune-error = { workspace = true } -kitsune-http-client = { workspace = true } +iso8601-timestamp.workspace = true +kitsune-db.workspace = true +kitsune-derive.workspace = true +kitsune-error.workspace = true +kitsune-http-client.workspace = true lantern-client-sdk = { package = "client-sdk", git = "https://github.com/Lantern-chat/client-sdk-rs.git", rev = "efb4288d9b107b48609802193d57b29f7ae395a1", default-features = false } -schaber = { workspace = true } +schaber.workspace = true smol_str = "0.3.2" [lints] diff --git a/crates/kitsune-error/Cargo.toml b/crates/kitsune-error/Cargo.toml index 427c1793c..92829f043 100644 --- a/crates/kitsune-error/Cargo.toml +++ b/crates/kitsune-error/Cargo.toml @@ -8,9 +8,9 @@ license.workspace = true [dependencies] axum-core = "0.4.5" eyre = "0.6.12" -garde = { workspace = true } +garde.workspace = true http = "1.1.0" -sonic-rs = { workspace = true } +sonic-rs.workspace = true sync_wrapper = "1.0.2" tracing = "0.1.41" diff --git a/crates/kitsune-federation-filter/Cargo.toml b/crates/kitsune-federation-filter/Cargo.toml index 7d02040bf..252bd87e3 100644 --- a/crates/kitsune-federation-filter/Cargo.toml +++ b/crates/kitsune-federation-filter/Cargo.toml @@ -7,10 +7,10 @@ license.workspace = true [dependencies] globset = "0.4.15" -kitsune-config = { workspace = true } -kitsune-derive = { workspace = true } -kitsune-error = { workspace = true } -kitsune-type = { workspace = true } +kitsune-config.workspace = true +kitsune-derive.workspace = true +kitsune-error.workspace = true +kitsune-type.workspace = true url = "2.5.4" [lints] diff --git a/crates/kitsune-federation/Cargo.toml b/crates/kitsune-federation/Cargo.toml index 5ff563b8b..a21eff5dd 100644 --- a/crates/kitsune-federation/Cargo.toml +++ b/crates/kitsune-federation/Cargo.toml @@ -6,20 +6,20 @@ version.workspace = true license.workspace = true [dependencies] -kitsune-activitypub = { workspace = true } -kitsune-cache = { workspace = true } -kitsune-config = { workspace = true } -kitsune-core = { workspace = true } -kitsune-db = { workspace = true } -kitsune-embed = { workspace = true } -kitsune-federation-filter = { workspace = true } +kitsune-activitypub.workspace = true +kitsune-cache.workspace = true +kitsune-config.workspace = true +kitsune-core.workspace = true +kitsune-db.workspace = true +kitsune-embed.workspace = true +kitsune-federation-filter.workspace = true kitsune-http-client.workspace = true -kitsune-search = { workspace = true } -kitsune-service = { workspace = true } -kitsune-url = { workspace = true } -kitsune-wasm-mrf = { workspace = true } -kitsune-webfinger = { workspace = true } -triomphe = { workspace = true } +kitsune-search.workspace = true +kitsune-service.workspace = true +kitsune-url.workspace = true +kitsune-wasm-mrf.workspace = true +kitsune-webfinger.workspace = true +triomphe.workspace = true typed-builder = "0.20.0" [lints] diff --git a/crates/kitsune-http-client/Cargo.toml b/crates/kitsune-http-client/Cargo.toml index 8e73605ec..b6aba487d 100644 --- a/crates/kitsune-http-client/Cargo.toml +++ b/crates/kitsune-http-client/Cargo.toml @@ -6,16 +6,16 @@ edition.workspace = true license.workspace = true [dependencies] -asynk-strim = { workspace = true } +asynk-strim.workspace = true bytes = "1.9.0" futures-util = { version = "0.3.31", default-features = false, features = [ "alloc", ] } -hickory-resolver = { workspace = true } +hickory-resolver.workspace = true http = "1.1.0" http-body = "1.0.1" http-body-util = "0.1.2" -http-signatures = { workspace = true } +http-signatures.workspace = true hyper = "1.5.1" hyper-util = { version = "0.1.10", features = [ "client-legacy", @@ -31,12 +31,12 @@ hyper-rustls = { version = "0.27.3", default-features = false, features = [ "ring", "tls12", ] } -kitsune-core = { workspace = true } -kitsune-type = { workspace = true } +kitsune-core.workspace = true +kitsune-type.workspace = true pin-project = "1.1.7" serde = "1.0.215" -simdutf8 = { workspace = true } -sonic-rs = { workspace = true } +simdutf8.workspace = true +sonic-rs.workspace = true tower = { version = "0.5.1", features = ["util"] } tower-http = { version = "0.6.2", features = [ # Explicitly exclude `zstd` diff --git a/crates/kitsune-jobs/Cargo.toml b/crates/kitsune-jobs/Cargo.toml index 0ab0ab22c..196dfa18b 100644 --- a/crates/kitsune-jobs/Cargo.toml +++ b/crates/kitsune-jobs/Cargo.toml @@ -6,17 +6,17 @@ version.workspace = true license.workspace = true [dependencies] -athena = { workspace = true } +athena.workspace = true derive_more = { version = "1.0.0", features = ["from"] } -diesel = { workspace = true } -diesel-async = { workspace = true } +diesel.workspace = true +diesel-async.workspace = true futures-util = "0.3.31" -kitsune-core = { workspace = true } -kitsune-db = { workspace = true } -kitsune-email = { workspace = true } -kitsune-error = { workspace = true } +kitsune-core.workspace = true +kitsune-db.workspace = true +kitsune-email.workspace = true +kitsune-error.workspace = true serde = { version = "1.0.215", features = ["derive"] } -speedy-uuid = { workspace = true } +speedy-uuid.workspace = true tracing = "0.1.41" typed-builder = "0.20.0" diff --git a/crates/kitsune-language/Cargo.toml b/crates/kitsune-language/Cargo.toml index 4cf8c6a8c..32627c775 100644 --- a/crates/kitsune-language/Cargo.toml +++ b/crates/kitsune-language/Cargo.toml @@ -6,9 +6,9 @@ version.workspace = true license.workspace = true [dependencies] -diesel = { workspace = true } -diesel-async = { workspace = true } -kitsune-config = { workspace = true } +diesel.workspace = true +diesel-async.workspace = true +kitsune-config.workspace = true isolang = { version = "2.4.0", features = [ "english_names", "list_languages", diff --git a/crates/kitsune-mastodon/Cargo.toml b/crates/kitsune-mastodon/Cargo.toml index 29f9c8bd4..712f72633 100644 --- a/crates/kitsune-mastodon/Cargo.toml +++ b/crates/kitsune-mastodon/Cargo.toml @@ -6,23 +6,23 @@ version.workspace = true license.workspace = true [dependencies] -diesel = { workspace = true } -diesel-async = { workspace = true } +diesel.workspace = true +diesel-async.workspace = true futures-util = "0.3.31" -iso8601-timestamp = { workspace = true } -kitsune-cache = { workspace = true } -kitsune-db = { workspace = true } -kitsune-embed = { workspace = true } -kitsune-error = { workspace = true } -kitsune-service = { workspace = true } -kitsune-type = { workspace = true } -kitsune-url = { workspace = true } -kitsune-util = { workspace = true } +iso8601-timestamp.workspace = true +kitsune-cache.workspace = true +kitsune-db.workspace = true +kitsune-embed.workspace = true +kitsune-error.workspace = true +kitsune-service.workspace = true +kitsune-type.workspace = true +kitsune-url.workspace = true +kitsune-util.workspace = true mime = "0.3.17" serde = "1.0.215" smol_str = "0.3.2" -sonic-rs = { workspace = true } -speedy-uuid = { workspace = true } +sonic-rs.workspace = true +speedy-uuid.workspace = true tracing = "0.1.41" typed-builder = "0.20.0" diff --git a/crates/kitsune-observability/Cargo.toml b/crates/kitsune-observability/Cargo.toml index c1ca10dde..32643cc8f 100644 --- a/crates/kitsune-observability/Cargo.toml +++ b/crates/kitsune-observability/Cargo.toml @@ -10,9 +10,9 @@ async-trait = "0.1.83" eyre = "0.6.12" http-body-util = "0.1.2" hyper = { version = "1.5.1", default-features = false } -kitsune-config = { workspace = true } -kitsune-core = { workspace = true } -kitsune-http-client = { workspace = true } +kitsune-config.workspace = true +kitsune-core.workspace = true +kitsune-http-client.workspace = true opentelemetry = { version = "0.27.1", default-features = false, features = [ "trace", ] } diff --git a/crates/kitsune-oidc/Cargo.toml b/crates/kitsune-oidc/Cargo.toml index b0348c533..494bd8f83 100644 --- a/crates/kitsune-oidc/Cargo.toml +++ b/crates/kitsune-oidc/Cargo.toml @@ -7,12 +7,12 @@ license.workspace = true [dependencies] enum_dispatch = "0.3.13" -fred = { workspace = true } +fred.workspace = true http-body-util = "0.1.2" -kitsune-config = { workspace = true } -kitsune-derive = { workspace = true } -kitsune-error = { workspace = true } -kitsune-http-client = { workspace = true } +kitsune-config.workspace = true +kitsune-derive.workspace = true +kitsune-error.workspace = true +kitsune-http-client.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 = [ @@ -22,8 +22,8 @@ openidconnect = { version = "4.0.0-rc.1", default-features = false, features = [ "timing-resistant-secret-traits", ] } serde = { version = "1.0.215", features = ["derive"] } -sonic-rs = { workspace = true } -speedy-uuid = { workspace = true } +sonic-rs.workspace = true +speedy-uuid.workspace = true thiserror = "2.0.3" url = "2.5.4" diff --git a/crates/kitsune-s3/Cargo.toml b/crates/kitsune-s3/Cargo.toml index e02f5cd84..dee09ec74 100644 --- a/crates/kitsune-s3/Cargo.toml +++ b/crates/kitsune-s3/Cargo.toml @@ -9,15 +9,15 @@ license.workspace = true bytes = "1.9.0" futures-util = { version = "0.3.31", default-features = false } http = "1.1.0" -kitsune-error = { workspace = true } -kitsune-http-client = { workspace = true } +kitsune-error.workspace = true +kitsune-http-client.workspace = true quick-xml = { version = "0.37.1", features = ["serialize"] } rusty-s3 = "0.5.0" serde = { version = "1.0.215", features = ["derive"] } typed-builder = "0.20.0" [dev-dependencies] -kitsune-test = { workspace = true } +kitsune-test.workspace = true tokio = { workspace = true, features = ["macros", "rt"] } [lints] diff --git a/crates/kitsune-search/Cargo.toml b/crates/kitsune-search/Cargo.toml index ec1429090..a1c9dbc1c 100644 --- a/crates/kitsune-search/Cargo.toml +++ b/crates/kitsune-search/Cargo.toml @@ -8,24 +8,24 @@ license.workspace = true [dependencies] async-trait = "0.1.83" bytes = "1.9.0" -diesel = { workspace = true } -diesel-async = { workspace = true } -diesel_full_text_search = { workspace = true } +diesel.workspace = true +diesel-async.workspace = true +diesel_full_text_search.workspace = true enum_dispatch = "0.3.13" futures-io = "0.3.31" futures-util = "0.3.31" http = "1.1.0" -kitsune-config = { workspace = true } -kitsune-db = { workspace = true } -kitsune-derive = { workspace = true } -kitsune-error = { workspace = true } -kitsune-http-client = { workspace = true } -kitsune-language = { workspace = true } +kitsune-config.workspace = true +kitsune-db.workspace = true +kitsune-derive.workspace = true +kitsune-error.workspace = true +kitsune-http-client.workspace = true +kitsune-language.workspace = true meilisearch-sdk = { version = "0.27.1", default-features = false } pin-project-lite = "0.2.15" serde = { version = "1.0.215", features = ["derive"] } serde_urlencoded = "0.7.1" -speedy-uuid = { workspace = true } +speedy-uuid.workspace = true strum = { version = "0.26.3", features = ["derive"] } tracing = "0.1.41" diff --git a/crates/kitsune-service/Cargo.toml b/crates/kitsune-service/Cargo.toml index 9f994dd32..4f1763482 100644 --- a/crates/kitsune-service/Cargo.toml +++ b/crates/kitsune-service/Cargo.toml @@ -8,49 +8,49 @@ license.workspace = true [dependencies] ahash = "0.8.11" argon2 = "0.5.3" -asynk-strim = { workspace = true } -athena = { workspace = true } -blowocking = { workspace = true } +asynk-strim.workspace = true +athena.workspace = true +blowocking.workspace = true bytes = "1.9.0" derive_builder = "0.20.2" -diesel = { workspace = true } -diesel-async = { workspace = true } +diesel.workspace = true +diesel-async.workspace = true eyre = "0.6.12" -fred = { workspace = true } +fred.workspace = true futures-util = "0.3.31" -garde = { workspace = true } +garde.workspace = true http = "1.1.0" img-parts = "0.3.1" -iso8601-timestamp = { workspace = true } -kitsune-cache = { workspace = true } -kitsune-captcha = { workspace = true } -kitsune-config = { workspace = true } -kitsune-core = { workspace = true } -kitsune-db = { workspace = true } -kitsune-derive = { workspace = true } -kitsune-email = { workspace = true } -kitsune-embed = { workspace = true } -kitsune-error = { workspace = true } -kitsune-http-client = { workspace = true } -kitsune-jobs = { workspace = true } -kitsune-language = { workspace = true } -kitsune-search = { workspace = true } -kitsune-storage = { workspace = true } -kitsune-url = { workspace = true } -kitsune-util = { workspace = true } +iso8601-timestamp.workspace = true +kitsune-cache.workspace = true +kitsune-captcha.workspace = true +kitsune-config.workspace = true +kitsune-core.workspace = true +kitsune-db.workspace = true +kitsune-derive.workspace = true +kitsune-email.workspace = true +kitsune-embed.workspace = true +kitsune-error.workspace = true +kitsune-http-client.workspace = true +kitsune-jobs.workspace = true +kitsune-language.workspace = true +kitsune-search.workspace = true +kitsune-storage.workspace = true +kitsune-url.workspace = true +kitsune-util.workspace = true mime = "0.3.17" password-hash = { version = "0.5.0", features = ["std"] } pkcs8 = "0.10.2" -post-process = { workspace = true } +post-process.workspace = true rand = "0.8.5" rsa = "0.9.7" rusty-s3 = { version = "0.5.0", default-features = false } serde = "1.0.215" smol_str = "0.3.2" -speedy-uuid = { workspace = true } +speedy-uuid.workspace = true tokio = { workspace = true, features = ["macros", "sync"] } tracing = "0.1.41" -triomphe = { workspace = true } +triomphe.workspace = true typed-builder = "0.20.0" url = "2.5.4" zxcvbn = { version = "3.1.0", default-features = false } @@ -59,12 +59,12 @@ zxcvbn = { version = "3.1.0", default-features = false } hex-simd = "0.8.0" http-body-util = "0.1.2" hyper = "1.5.1" -kitsune-activitypub = { workspace = true } -kitsune-config = { workspace = true } -kitsune-federation-filter = { workspace = true } -kitsune-jobs = { workspace = true } -kitsune-test = { workspace = true } -kitsune-webfinger = { workspace = true } +kitsune-activitypub.workspace = true +kitsune-config.workspace = true +kitsune-federation-filter.workspace = true +kitsune-jobs.workspace = true +kitsune-test.workspace = true +kitsune-webfinger.workspace = true pretty_assertions = "1.4.1" tempfile = "3.14.0" tower = { version = "0.5.1", default-features = false, features = ["util"] } diff --git a/crates/kitsune-storage/Cargo.toml b/crates/kitsune-storage/Cargo.toml index 9f38b52d9..ab68171a4 100644 --- a/crates/kitsune-storage/Cargo.toml +++ b/crates/kitsune-storage/Cargo.toml @@ -9,12 +9,12 @@ license.workspace = true bytes = "1.9.0" derive_more = { version = "1.0.0", features = ["from"] } futures-util = "0.3.31" -kitsune-error = { workspace = true } -kitsune-s3 = { workspace = true } +kitsune-error.workspace = true +kitsune-s3.workspace = true rusty-s3 = { version = "0.5.0", default-features = false } tokio = { workspace = true, features = ["fs", "io-util"] } tokio-util = { version = "0.7.12", features = ["io"] } -triomphe = { workspace = true } +triomphe.workspace = true [dev-dependencies] tempfile = "3.14.0" diff --git a/crates/kitsune-test/Cargo.toml b/crates/kitsune-test/Cargo.toml index de1db6d93..59c8a10c0 100644 --- a/crates/kitsune-test/Cargo.toml +++ b/crates/kitsune-test/Cargo.toml @@ -7,20 +7,20 @@ license.workspace = true [dependencies] bytes = "1.9.0" -diesel-async = { workspace = true } -fred = { workspace = true } +diesel-async.workspace = true +fred.workspace = true futures-util = "0.3.31" http = "1.1.0" http-body-util = "0.1.2" isolang = "2.4.0" -kitsune-config = { workspace = true } -kitsune-db = { workspace = true } -kitsune-s3 = { workspace = true } +kitsune-config.workspace = true +kitsune-db.workspace = true +kitsune-s3.workspace = true pin-project-lite = "0.2.15" rand = "0.8.5" rusty-s3 = { version = "0.5.0", default-features = false } tokio = { workspace = true, features = ["time"] } -triomphe = { workspace = true } +triomphe.workspace = true url = "2.5.4" uuid = { version = "1.11.0", features = ["fast-rng", "v4"] } diff --git a/crates/kitsune-type/Cargo.toml b/crates/kitsune-type/Cargo.toml index 8f14bd41d..c258cf5e0 100644 --- a/crates/kitsune-type/Cargo.toml +++ b/crates/kitsune-type/Cargo.toml @@ -6,14 +6,14 @@ edition.workspace = true license.workspace = true [dependencies] -iso8601-timestamp = { workspace = true } +iso8601-timestamp.workspace = true serde = { version = "1.0.215", features = ["derive"] } serde_with = { version = "3.11.0", default-features = false, features = [ "alloc", "macros", ] } smol_str = { version = "0.3.2", features = ["serde"] } -sonic-rs = { workspace = true } +sonic-rs.workspace = true speedy-uuid = { workspace = true, features = ["diesel"] } strum = { version = "0.26.3", features = ["derive"] } diff --git a/crates/kitsune-url/Cargo.toml b/crates/kitsune-url/Cargo.toml index bd67e76bb..9167e72bf 100644 --- a/crates/kitsune-url/Cargo.toml +++ b/crates/kitsune-url/Cargo.toml @@ -6,9 +6,9 @@ version.workspace = true license.workspace = true [dependencies] -kitsune-derive = { workspace = true } +kitsune-derive.workspace = true smol_str = "0.3.2" -speedy-uuid = { workspace = true } +speedy-uuid.workspace = true [lints] workspace = true diff --git a/crates/kitsune-util/Cargo.toml b/crates/kitsune-util/Cargo.toml index a794cfa9a..1e1bc4b5e 100644 --- a/crates/kitsune-util/Cargo.toml +++ b/crates/kitsune-util/Cargo.toml @@ -7,14 +7,14 @@ license.workspace = true [dependencies] bubble-bath = "0.2.1" -iso8601-timestamp = { workspace = true } -kitsune-type = { workspace = true } +iso8601-timestamp.workspace = true +kitsune-type.workspace = true pulldown-cmark = { version = "0.12.2", default-features = false, features = [ "html", "simd", ] } rand = "0.8.5" -speedy-uuid = { workspace = true } +speedy-uuid.workspace = true tokio = { workspace = true, features = ["macros"] } [lints] diff --git a/crates/kitsune-wasm-mrf/Cargo.toml b/crates/kitsune-wasm-mrf/Cargo.toml index c5707ee8e..b910effc2 100644 --- a/crates/kitsune-wasm-mrf/Cargo.toml +++ b/crates/kitsune-wasm-mrf/Cargo.toml @@ -12,25 +12,25 @@ blake3 = "1.5.5" color-eyre = "0.6.3" derive_more = { version = "1.0.0", features = ["from"] } enum_dispatch = "0.3.13" -fred = { workspace = true } +fred.workspace = true futures-util = { version = "0.3.31", default-features = false, features = [ "alloc", ] } http = "1.1.0" http-body-util = "0.1.2" -kitsune-config = { workspace = true } -kitsune-derive = { workspace = true } -kitsune-error = { workspace = true } -kitsune-http-client = { workspace = true } -kitsune-type = { workspace = true } +kitsune-config.workspace = true +kitsune-derive.workspace = true +kitsune-error.workspace = true +kitsune-http-client.workspace = true +kitsune-type.workspace = true mrf-manifest = { workspace = true, features = ["decode"] } redb = { version = "2.2.0", features = ["logging"] } slab = "0.4.9" smol_str = "0.3.2" -sonic-rs = { workspace = true } +sonic-rs.workspace = true tokio = { workspace = true, features = ["fs"] } tracing = "0.1.41" -triomphe = { workspace = true } +triomphe.workspace = true walkdir = "2.5.0" wasmtime = { version = "27.0.0", default-features = false, features = [ "addr2line", diff --git a/crates/kitsune-webfinger/Cargo.toml b/crates/kitsune-webfinger/Cargo.toml index daa03a519..af3d85369 100644 --- a/crates/kitsune-webfinger/Cargo.toml +++ b/crates/kitsune-webfinger/Cargo.toml @@ -7,24 +7,24 @@ license.workspace = true [dependencies] async-trait = "0.1.83" -fred = { workspace = true } +fred.workspace = true futures-util = "0.3.31" http = "1.1.0" -kitsune-cache = { workspace = true } -kitsune-core = { workspace = true } -kitsune-error = { workspace = true } -kitsune-http-client = { workspace = true } -kitsune-type = { workspace = true } -kitsune-util = { workspace = true } +kitsune-cache.workspace = true +kitsune-core.workspace = true +kitsune-error.workspace = true +kitsune-http-client.workspace = true +kitsune-type.workspace = true +kitsune-util.workspace = true tracing = "0.1.41" -triomphe = { workspace = true } +triomphe.workspace = true urlencoding = "2.1.3" [dev-dependencies] http-body-util = "0.1.2" hyper = "1.5.1" pretty_assertions = "1.4.1" -sonic-rs = { workspace = true } +sonic-rs.workspace = true tokio = { workspace = true, features = ["macros"] } tower = { version = "0.5.1", default-features = false, features = ["util"] } diff --git a/kitsune-cli/Cargo.toml b/kitsune-cli/Cargo.toml index 3123d1c88..7fa5282b3 100644 --- a/kitsune-cli/Cargo.toml +++ b/kitsune-cli/Cargo.toml @@ -12,18 +12,18 @@ license = false eula = false [dependencies] -clap = { workspace = true } +clap.workspace = true color-eyre = "0.6.3" -diesel = { workspace = true } -diesel-async = { workspace = true } +diesel.workspace = true +diesel-async.workspace = true dotenvy = "0.15.7" envy = "0.4.2" -kitsune-config = { workspace = true } -kitsune-core = { workspace = true } -kitsune-db = { workspace = true } -kitsune-error = { workspace = true } +kitsune-config.workspace = true +kitsune-core.workspace = true +kitsune-db.workspace = true +kitsune-error.workspace = true serde = { version = "1.0.215", features = ["derive"] } -speedy-uuid = { workspace = true } +speedy-uuid.workspace = true tokio = { workspace = true, features = ["full"] } tracing-subscriber = "0.3.18" diff --git a/kitsune-job-runner/Cargo.toml b/kitsune-job-runner/Cargo.toml index 619ecba75..42b5d43d8 100644 --- a/kitsune-job-runner/Cargo.toml +++ b/kitsune-job-runner/Cargo.toml @@ -12,28 +12,28 @@ license = false eula = false [dependencies] -athena = { workspace = true } -clap = { workspace = true } +athena.workspace = true +clap.workspace = true color-eyre = "0.6.3" -fred = { workspace = true } -just-retry = { workspace = true } -kitsune-config = { workspace = true } -kitsune-core = { workspace = true } -kitsune-db = { workspace = true } -kitsune-email = { workspace = true } -kitsune-error = { workspace = true } -kitsune-federation = { workspace = true } -kitsune-federation-filter = { workspace = true } +fred.workspace = true +just-retry.workspace = true +kitsune-config.workspace = true +kitsune-core.workspace = true +kitsune-db.workspace = true +kitsune-email.workspace = true +kitsune-error.workspace = true +kitsune-federation.workspace = true +kitsune-federation-filter.workspace = true kitsune-http-client.workspace = true -kitsune-jobs = { workspace = true } -kitsune-observability = { workspace = true } -kitsune-service = { workspace = true } -kitsune-url = { workspace = true } -kitsune-wasm-mrf = { workspace = true } +kitsune-jobs.workspace = true +kitsune-observability.workspace = true +kitsune-service.workspace = true +kitsune-url.workspace = true +kitsune-wasm-mrf.workspace = true mimalloc = "0.1.43" tokio = { workspace = true, features = ["full"] } tracing = "0.1.41" -triomphe = { workspace = true } +triomphe.workspace = true typed-builder = "0.20.0" [features] diff --git a/kitsune/Cargo.toml b/kitsune/Cargo.toml index e68e54356..b3c5574fb 100644 --- a/kitsune/Cargo.toml +++ b/kitsune/Cargo.toml @@ -15,10 +15,8 @@ license = false eula = false [dependencies] -athena = { workspace = true } +athena.workspace = true argon2 = { version = "0.5.3", features = ["std"] } -askama = { workspace = true } -askama_axum = "0.4.0" async-trait = "0.1.83" axum = { version = "0.7.9", features = ["macros", "multipart"] } axum-extra = { version = "0.9.6", features = [ @@ -28,67 +26,69 @@ axum-extra = { version = "0.9.6", features = [ "typed-header", ] } axum-flash = "0.8.0" -blowocking = { workspace = true } +blowocking.workspace = true bytes = "1.9.0" chrono = { version = "0.4.38", default-features = false } -clap = { workspace = true } +clap.workspace = true color-eyre = "0.6.3" cursiv = { workspace = true, features = ["axum"] } -diesel = { workspace = true } -diesel-async = { workspace = true } +diesel.workspace = true +diesel-async.workspace = true futures-util = "0.3.31" headers = "0.4.0" http = "1.1.0" http-body-util = "0.1.2" -http-signatures = { workspace = true } -iso8601-timestamp = { workspace = true } -itertools = { workspace = true } -kitsune-activitypub = { workspace = true } -kitsune-cache = { workspace = true } -kitsune-captcha = { workspace = true } -kitsune-config = { workspace = true } -kitsune-core = { workspace = true } -kitsune-db = { workspace = true } -kitsune-derive = { workspace = true } -kitsune-email = { workspace = true } -kitsune-embed = { workspace = true } -kitsune-error = { workspace = true } -kitsune-federation = { workspace = true } -kitsune-federation-filter = { workspace = true } -kitsune-http-client = { workspace = true } -kitsune-job-runner = { workspace = true } -kitsune-jobs = { workspace = true } -kitsune-language = { workspace = true } -kitsune-observability = { workspace = true } -kitsune-search = { workspace = true } -kitsune-service = { workspace = true } -kitsune-storage = { workspace = true } -kitsune-type = { workspace = true } -kitsune-url = { workspace = true } -kitsune-util = { workspace = true } -kitsune-wasm-mrf = { workspace = true } -kitsune-webfinger = { workspace = true } +http-signatures.workspace = true +iso8601-timestamp.workspace = true +itertools.workspace = true +kitsune-activitypub.workspace = true +kitsune-cache.workspace = true +kitsune-captcha.workspace = true +kitsune-config.workspace = true +kitsune-core.workspace = true +kitsune-db.workspace = true +kitsune-derive.workspace = true +kitsune-email.workspace = true +kitsune-embed.workspace = true +kitsune-error.workspace = true +kitsune-federation.workspace = true +kitsune-federation-filter.workspace = true +kitsune-http-client.workspace = true +kitsune-job-runner.workspace = true +kitsune-jobs.workspace = true +kitsune-language.workspace = true +kitsune-observability.workspace = true +kitsune-search.workspace = true +kitsune-service.workspace = true +kitsune-storage.workspace = true +kitsune-type.workspace = true +kitsune-url.workspace = true +kitsune-util.workspace = true +kitsune-wasm-mrf.workspace = true +kitsune-webfinger.workspace = true mimalloc = "0.1.43" mime = "0.3.17" mime_guess = { version = "2.0.5", default-features = false } +minijinja.workspace = true oxide-auth = "0.6.1" oxide-auth-async = "0.2.1" oxide-auth-axum = "0.5.0" +parking_lot = "0.12.3" rust-embed = { version = "8.5.0", features = ["include-exclude"] } scoped-futures = "0.1.4" serde = { version = "1.0.215", features = ["derive"] } serde_urlencoded = "0.7.1" -sonic-rs = { workspace = true } -simdutf8 = { workspace = true } -speedy-uuid = { workspace = true } +sonic-rs.workspace = true +simdutf8.workspace = true +speedy-uuid.workspace = true strum = { version = "0.26.3", features = ["derive"] } tempfile = "3.14.0" time = "0.3.36" tokio = { workspace = true, features = ["full"] } tokio-util = { version = "0.7.12", features = ["io"] } tower = { version = "0.5.1", features = ["util"] } -tower-stop-using-brave = { workspace = true } -tower-x-clacks-overhead = { workspace = true } +tower-stop-using-brave.workspace = true +tower-x-clacks-overhead.workspace = true tower-http = { version = "0.6.2", features = [ "catch-panic", "cors", @@ -97,10 +97,10 @@ tower-http = { version = "0.6.2", features = [ "timeout", "trace", ] } -tower-http-digest = { workspace = true } +tower-http-digest.workspace = true tracing = "0.1.41" -trials = { workspace = true } -triomphe = { workspace = true } +trials.workspace = true +triomphe.workspace = true typed-builder = "0.20.0" url = "2.5.4" @@ -123,9 +123,9 @@ kitsune-mastodon = { workspace = true, optional = true } kitsune-oidc = { workspace = true, optional = true } [dev-dependencies] -kitsune-http-client = { workspace = true } -kitsune-test = { workspace = true } -fred = { workspace = true } +kitsune-http-client.workspace = true +kitsune-test.workspace = true +fred.workspace = true [features] default = ["graphql-api", "mastodon-api", "oidc"] diff --git a/kitsune/src/http/extractor/json.rs b/kitsune/src/http/extractor/json.rs index 9d406209b..9d087408b 100644 --- a/kitsune/src/http/extractor/json.rs +++ b/kitsune/src/http/extractor/json.rs @@ -1,5 +1,5 @@ -use askama_axum::IntoResponse; use async_trait::async_trait; +use axum::response::IntoResponse; use axum::{body::Body, extract::FromRequest, response::Response}; use bytes::{BufMut, Bytes, BytesMut}; use http::{header, HeaderMap, HeaderValue, Request, StatusCode}; diff --git a/kitsune/src/lib.rs b/kitsune/src/lib.rs index d93412de5..5f016594d 100644 --- a/kitsune/src/lib.rs +++ b/kitsune/src/lib.rs @@ -6,6 +6,7 @@ pub mod http; pub mod oauth2; pub mod signal; pub mod state; +pub mod template; use self::{ oauth2::{OAuth2Service, OAuthEndpoint}, diff --git a/kitsune/src/oauth2/mod.rs b/kitsune/src/oauth2/mod.rs index 03e4f12ca..3c349b887 100644 --- a/kitsune/src/oauth2/mod.rs +++ b/kitsune/src/oauth2/mod.rs @@ -1,6 +1,4 @@ -use askama::Template; -use askama_axum::IntoResponse; -use axum::response::{Redirect, Response}; +use axum::response::{Html, IntoResponse, Redirect, Response}; use chrono::Utc; use diesel_async::RunQueryDsl; use iso8601_timestamp::Timestamp; @@ -14,6 +12,7 @@ use kitsune_error::{Error, Result}; use kitsune_url::UrlService; use kitsune_util::generate_secret; use oxide_auth::endpoint::Scope; +use serde::Serialize; use speedy_uuid::Uuid; use std::str::{self, FromStr}; use strum::{AsRefStr, EnumIter, EnumMessage, EnumString}; @@ -78,8 +77,7 @@ pub struct CreateApp { redirect_uris: String, } -#[derive(Template)] -#[template(path = "oauth/token.html")] +#[derive(Serialize)] struct ShowTokenPage { app_name: String, domain: String, @@ -138,12 +136,18 @@ impl OAuth2Service { })?; if application.redirect_uri == SHOW_TOKEN_URI { - Ok(ShowTokenPage { - app_name: application.name, - domain: self.url_service.domain().into(), - token: authorization_code.code, - } - .into_response()) + let page = crate::template::templates() + .render( + "oauth/token.html", + &ShowTokenPage { + app_name: application.name, + domain: self.url_service.domain().into(), + token: authorization_code.code, + }, + ) + .unwrap(); + + Ok(Html(page).into_response()) } else { let mut url = Url::from_str(&application.redirect_uri)?; url.query_pairs_mut() diff --git a/kitsune/src/oauth2/solicitor.rs b/kitsune/src/oauth2/solicitor.rs index 7468e8f0a..b3e6938f4 100644 --- a/kitsune/src/oauth2/solicitor.rs +++ b/kitsune/src/oauth2/solicitor.rs @@ -1,5 +1,4 @@ use super::OAuthScope; -use askama::Template; use async_trait::async_trait; use cursiv::CsrfHandle; use diesel::{OptionalExtension, QueryDsl}; @@ -9,14 +8,13 @@ use kitsune_error::Result; use oxide_auth::endpoint::{OAuthError, OwnerConsent, QueryParameter, Solicitation, WebRequest}; use oxide_auth_async::endpoint::OwnerSolicitor; use oxide_auth_axum::{OAuthRequest, OAuthResponse, WebError}; +use serde::Serialize; use speedy_uuid::Uuid; use std::{borrow::Cow, str::FromStr}; -use strum::EnumMessage; use trials::attempt; use typed_builder::TypedBuilder; -#[derive(Template)] -#[template(path = "oauth/consent.html")] +#[derive(Serialize)] struct ConsentPage<'a> { authenticated_username: &'a str, app_name: &'a str, @@ -25,6 +23,7 @@ struct ConsentPage<'a> { scopes: &'a [OAuthScope], } +#[derive(Serialize)] struct PageQueryParams { client_id: String, csrf_token: Option, @@ -108,15 +107,18 @@ impl OAuthOwnerSolicitor { let user_id = self.authenticated_user.id.to_string(); let csrf_token = self.csrf_handle.sign(user_id); // TODO: BAD DO NOT USE USER-ID - let body = ConsentPage { - authenticated_username: &self.authenticated_user.username, - app_name: &app_name, - csrf_token: csrf_token.as_str(), - query, - scopes: &scopes, - } - .render() - .map_err(|err| WebError::InternalError(Some(err.to_string())))?; + let body = crate::template::templates() + .render( + "oauth/consent.html", + &ConsentPage { + authenticated_username: &self.authenticated_user.username, + app_name: &app_name, + csrf_token: csrf_token.as_str(), + query, + scopes: &scopes, + }, + ) + .map_err(|err| WebError::InternalError(Some(err.to_string())))?; OwnerConsent::InProgress( OAuthResponse::default() diff --git a/kitsune/src/template.rs b/kitsune/src/template.rs new file mode 100644 index 000000000..a7b6cf25f --- /dev/null +++ b/kitsune/src/template.rs @@ -0,0 +1,38 @@ +use core::str; +use parking_lot::RwLock; +use rust_embed::RustEmbed; +use std::sync::LazyLock; + +static ENVIRONMENT: LazyLock>> = LazyLock::new(|| { + let mut environment = minijinja::Environment::new(); + environment.set_loader(|path| { + let maybe_data = TemplateDir::get(path).map(|embedded_file| embedded_file.data); + let maybe_template = maybe_data + .map(|data| str::from_utf8(&data).map(ToString::to_string)) + .transpose() + .map_err(|error| { + minijinja::Error::new(minijinja::ErrorKind::CannotDeserialize, error.to_string()) + })?; + + Ok(maybe_template) + }); + + RwLock::new(environment) +}); + +#[derive(RustEmbed)] +#[folder = "templates"] +struct TemplateDir; + +pub fn get( + name: &str, +) -> parking_lot::RwLockReadGuard<'static, Option>> { + let env_handle = ENVIRONMENT.read(); + + env_handle.map(|env| { + env.get_template(name) + .inspect_err(|error| error!(?error, "failed to load template")) + .ok() + .map(|template| template.clone()) + }) +} diff --git a/lib/athena/Cargo.toml b/lib/athena/Cargo.toml index d2093a548..3bf8b72fb 100644 --- a/lib/athena/Cargo.toml +++ b/lib/athena/Cargo.toml @@ -14,9 +14,9 @@ ahash = "0.8.11" async-trait = "0.1.83" either = { version = "1.13.0", default-features = false, optional = true } futures-util = { version = "0.3.31", default-features = false } -iso8601-timestamp = { workspace = true } +iso8601-timestamp.workspace = true fred = { workspace = true, optional = true } -just-retry = { workspace = true } +just-retry.workspace = true rand = { version = "0.8.5", optional = true } serde = { version = "1.0.215", features = ["derive"] } smol_str = "0.3.2" @@ -26,7 +26,7 @@ thiserror = "2.0.3" tokio = { workspace = true, features = ["macros", "rt", "sync"] } tokio-util = { version = "0.7.12", features = ["rt"] } tracing = "0.1.41" -triomphe = { workspace = true } +triomphe.workspace = true typed-builder = "0.20.0" typetag = "0.2.18" unsize = "1.1.0" @@ -35,7 +35,7 @@ unsize = "1.1.0" redis = ["dep:either", "dep:fred", "dep:rand", "dep:sonic-rs"] [dev-dependencies] -kitsune-test = { workspace = true } +kitsune-test.workspace = true postcard = { version = "1.1.0", default-features = false, features = ["alloc"] } tracing-subscriber = "0.3.18" diff --git a/lib/cursiv/Cargo.toml b/lib/cursiv/Cargo.toml index bbae97e8d..18f6854c0 100644 --- a/lib/cursiv/Cargo.toml +++ b/lib/cursiv/Cargo.toml @@ -14,7 +14,7 @@ http = "1.1.0" pin-project-lite = "0.2.15" rand = "0.8.5" tower = { version = "0.5.1", default-features = false } -triomphe = { workspace = true } +triomphe.workspace = true zeroize = { version = "1.8.1", features = ["derive"] } # `axum` feature diff --git a/lib/fast-cjson/Cargo.toml b/lib/fast-cjson/Cargo.toml index 5df529e3d..9d576017f 100644 --- a/lib/fast-cjson/Cargo.toml +++ b/lib/fast-cjson/Cargo.toml @@ -13,7 +13,7 @@ harness = false icu_normalizer = "1.5.0" memchr = "2.7.4" serde = "1.0.215" -sonic-rs = { workspace = true } +sonic-rs.workspace = true [dev-dependencies] divan = "0.1.16" diff --git a/lib/geomjeungja/Cargo.toml b/lib/geomjeungja/Cargo.toml index 010811aa4..0236d1de1 100644 --- a/lib/geomjeungja/Cargo.toml +++ b/lib/geomjeungja/Cargo.toml @@ -7,20 +7,20 @@ license = "MIT OR Apache-2.0" [dependencies] async-trait = "0.1.83" -hickory-resolver = { workspace = true } +hickory-resolver.workspace = true rand = "0.8.5" serde = { version = "1.0.215", features = ["derive"] } -simdutf8 = { workspace = true } +simdutf8.workspace = true thiserror = "2.0.3" tracing = "0.1.41" -triomphe = { workspace = true } +triomphe.workspace = true typed-builder = "0.20.0" unsize = "1.1.0" [dev-dependencies] insta = { version = "1.41.1", features = ["json"] } rand_xorshift = "0.3.0" -sonic-rs = { workspace = true } +sonic-rs.workspace = true tokio = { workspace = true, features = ["macros", "rt"] } [lints] diff --git a/lib/http-signatures-cli/Cargo.toml b/lib/http-signatures-cli/Cargo.toml index 2bb819dd2..92847127b 100644 --- a/lib/http-signatures-cli/Cargo.toml +++ b/lib/http-signatures-cli/Cargo.toml @@ -6,8 +6,8 @@ version.workspace = true license = "MIT OR Apache-2.0" [dependencies] -clap = { workspace = true } -http-signatures = { workspace = true } +clap.workspace = true +http-signatures.workspace = true miette = { version = "7.4.0", features = ["fancy"] } owo-colors = { version = "4.1.0", features = ["supports-colors"] } diff --git a/lib/http-signatures/Cargo.toml b/lib/http-signatures/Cargo.toml index c643a7423..3b935033d 100644 --- a/lib/http-signatures/Cargo.toml +++ b/lib/http-signatures/Cargo.toml @@ -20,7 +20,7 @@ const-oid = { version = "0.9.6", features = ["db"] } derive_builder = "0.20.2" http = "1.1.0" httpdate = "1.0.3" -itertools = { workspace = true } +itertools.workspace = true lexical-parse-integer = "1.0.2" logos = "0.14.2" miette = "7.4.0" @@ -28,7 +28,7 @@ pkcs8 = { version = "0.10.2", features = ["pem", "std"] } ring = { version = "0.17.8", features = ["std"] } scoped-futures = { version = "0.1.4", default-features = false } thiserror = "2.0.3" -tick-tock-mock = { workspace = true } +tick-tock-mock.workspace = true tracing = { version = "0.1.41", default-features = false, optional = true } [dev-dependencies] diff --git a/lib/mrf-manifest/Cargo.toml b/lib/mrf-manifest/Cargo.toml index ba4e8762b..9bc68ac30 100644 --- a/lib/mrf-manifest/Cargo.toml +++ b/lib/mrf-manifest/Cargo.toml @@ -18,7 +18,7 @@ wasmparser = { version = "0.221.0", optional = true } [dev-dependencies] insta = { version = "1.41.1", default-features = false, features = ["json"] } -sonic-rs = { workspace = true } +sonic-rs.workspace = true wat = "1.221.0" [features] diff --git a/lib/mrf-tool/Cargo.toml b/lib/mrf-tool/Cargo.toml index 0bd4589b1..58663aa6c 100644 --- a/lib/mrf-tool/Cargo.toml +++ b/lib/mrf-tool/Cargo.toml @@ -7,7 +7,7 @@ version.workspace = true license = "MIT OR Apache-2.0" [dependencies] -clap = { workspace = true } +clap.workspace = true color-eyre = "0.6.3" colored_json = "5.0.0" mrf-manifest = { workspace = true, features = [ @@ -15,11 +15,11 @@ mrf-manifest = { workspace = true, features = [ "encode", "serialise", ] } -sonic-rs = { workspace = true } +sonic-rs.workspace = true wasmparser = "0.221.0" [dev-dependencies] -sonic-rs = { workspace = true } +sonic-rs.workspace = true wat = "1.221.0" [lints] diff --git a/lib/tower-x-clacks-overhead/Cargo.toml b/lib/tower-x-clacks-overhead/Cargo.toml index fd4025fc4..b9e70fb35 100644 --- a/lib/tower-x-clacks-overhead/Cargo.toml +++ b/lib/tower-x-clacks-overhead/Cargo.toml @@ -7,11 +7,11 @@ license = "MIT OR Apache-2.0" [dependencies] http = "1.1.0" -itertools = { workspace = true } +itertools.workspace = true pin-project-lite = "0.2.15" tower-layer = "0.3.3" tower-service = "0.3.3" -triomphe = { workspace = true } +triomphe.workspace = true [dev-dependencies] futures-test = "0.3.31" diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 1e34d7fce..da1adb3fa 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -8,7 +8,7 @@ publish = false [dependencies] argh = "0.1.12" eyre = "0.6.12" -sonic-rs = { workspace = true } +sonic-rs.workspace = true tracing = { version = "0.1.41", default-features = false } tracing-subscriber = { version = "0.3.18", default-features = false, features = [ "ansi",