diff --git a/Cargo.lock b/Cargo.lock index c3537fd93..4eeb9f2e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,12 +1,14 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aead" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" dependencies = [ - "generic-array", + "generic-array 0.14.4", ] [[package]] @@ -41,7 +43,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" dependencies = [ "cipher", - "opaque-debug", + "opaque-debug 0.3.0", ] [[package]] @@ -51,7 +53,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" dependencies = [ "cipher", - "opaque-debug", + "opaque-debug 0.3.0", ] [[package]] @@ -353,6 +355,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + [[package]] name = "blake3" version = "0.3.8" @@ -365,7 +373,19 @@ dependencies = [ "cfg-if 0.1.10", "constant_time_eq", "crypto-mac 0.8.0", - "digest", + "digest 0.9.0", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", ] [[package]] @@ -374,7 +394,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array", + "generic-array 0.14.4", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", ] [[package]] @@ -391,6 +420,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "bstr" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" +dependencies = [ + "memchr", +] + [[package]] name = "bumpalo" version = "3.7.0" @@ -407,6 +445,18 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + [[package]] name = "bytes" version = "1.0.1" @@ -451,13 +501,23 @@ dependencies = [ "winapi", ] +[[package]] +name = "chrono-tz" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2554a3155fec064362507487171dcc4edc3df60cb10f3a1fb10ed8094822b120" +dependencies = [ + "chrono", + "parse-zoneinfo", +] + [[package]] name = "cipher" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" dependencies = [ - "generic-array", + "generic-array 0.14.4", ] [[package]] @@ -539,7 +599,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array", + "generic-array 0.14.4", "subtle", ] @@ -549,7 +609,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" dependencies = [ - "generic-array", + "generic-array 0.14.4", "subtle", ] @@ -588,13 +648,28 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +[[package]] +name = "deunicode" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array", + "generic-array 0.14.4", ] [[package]] @@ -609,6 +684,12 @@ version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + [[package]] name = "fastrand" version = "1.4.1" @@ -735,6 +816,15 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + [[package]] name = "generic-array" version = "0.14.4" @@ -773,10 +863,34 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" dependencies = [ - "opaque-debug", + "opaque-debug 0.3.0", "polyval", ] +[[package]] +name = "globset" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0fc1b9fa0e64ffb1aa5b95daa0f0f167734fd528b7c02eabc581d9d843649b1" +dependencies = [ + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", +] + +[[package]] +name = "globwalk" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" +dependencies = [ + "bitflags", + "ignore", + "walkdir", +] + [[package]] name = "gloo-timers" version = "0.2.1" @@ -805,7 +919,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f" dependencies = [ - "digest", + "digest 0.9.0", "hmac 0.10.1", ] @@ -816,7 +930,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" dependencies = [ "crypto-mac 0.8.0", - "digest", + "digest 0.9.0", ] [[package]] @@ -826,7 +940,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac 0.10.0", - "digest", + "digest 0.9.0", ] [[package]] @@ -881,6 +995,12 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" +[[package]] +name = "humansize" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" + [[package]] name = "idna" version = "0.2.3" @@ -892,6 +1012,24 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "ignore" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" +dependencies = [ + "crossbeam-utils", + "globset", + "lazy_static", + "log", + "memchr", + "regex", + "same-file", + "thread_local", + "walkdir", + "winapi-util", +] + [[package]] name = "indoc" version = "1.0.3" @@ -977,6 +1115,12 @@ dependencies = [ "value-bag", ] +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "matchers" version = "0.0.1" @@ -999,8 +1143,9 @@ dependencies = [ "async-std", "async-trait", "figment", - "oauth2", + "oauth2-types", "serde", + "tera", "thiserror", "tide", "tracing", @@ -1044,7 +1189,7 @@ dependencies = [ ] [[package]] -name = "oauth2" +name = "oauth2-types" version = "0.1.0" dependencies = [ "http", @@ -1062,6 +1207,12 @@ version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + [[package]] name = "opaque-debug" version = "0.3.0" @@ -1100,6 +1251,15 @@ dependencies = [ "syn", ] +[[package]] +name = "parse-zoneinfo" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" +dependencies = [ + "regex", +] + [[package]] name = "pear" version = "0.2.3" @@ -1129,6 +1289,49 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pest_meta" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" +dependencies = [ + "maplit", + "pest", + "sha-1", +] + [[package]] name = "pin-project" version = "1.0.7" @@ -1187,7 +1390,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" dependencies = [ "cpuid-bool", - "opaque-debug", + "opaque-debug 0.3.0", "universal-hash", ] @@ -1368,6 +1571,15 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "semver" version = "0.9.0" @@ -1438,6 +1650,18 @@ dependencies = [ "serde", ] +[[package]] +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + [[package]] name = "sha1" version = "0.6.0" @@ -1450,11 +1674,11 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" dependencies = [ - "block-buffer", + "block-buffer 0.9.0", "cfg-if 1.0.0", "cpufeatures", - "digest", - "opaque-debug", + "digest 0.9.0", + "opaque-debug 0.3.0", ] [[package]] @@ -1500,6 +1724,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" +[[package]] +name = "slug" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" +dependencies = [ + "deunicode", +] + [[package]] name = "smallvec" version = "1.6.1" @@ -1626,6 +1859,28 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "tera" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b6d9027cef72979d3436123f940cb372d5db2ae8afd328c482e8da7ff23aca" +dependencies = [ + "chrono", + "chrono-tz", + "globwalk", + "humansize", + "lazy_static", + "percent-encoding", + "pest", + "pest_derive", + "rand 0.8.3", + "regex", + "serde", + "serde_json", + "slug", + "unic-segment", +] + [[package]] name = "thiserror" version = "1.0.25" @@ -1823,6 +2078,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + [[package]] name = "uncased" version = "0.9.6" @@ -1832,6 +2093,56 @@ dependencies = [ "version_check", ] +[[package]] +name = "unic-char-property" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" +dependencies = [ + "unic-char-range", +] + +[[package]] +name = "unic-char-range" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" + +[[package]] +name = "unic-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" + +[[package]] +name = "unic-segment" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23" +dependencies = [ + "unic-ucd-segment", +] + +[[package]] +name = "unic-ucd-segment" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-version" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" +dependencies = [ + "unic-common", +] + [[package]] name = "unicode-bidi" version = "0.3.5" @@ -1868,7 +2179,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ - "generic-array", + "generic-array 0.14.4", "subtle", ] @@ -1908,6 +2219,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -2023,6 +2345,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index d4f9757bc..ce5431d1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = [ - "oauth2", + "oauth2-types", "matrix-authentication-service", ] diff --git a/matrix-authentication-service/Cargo.toml b/matrix-authentication-service/Cargo.toml index a39e70a38..afe0fc647 100644 --- a/matrix-authentication-service/Cargo.toml +++ b/matrix-authentication-service/Cargo.toml @@ -12,6 +12,7 @@ tracing = "0.1.26" tracing-subscriber = "0.2.18" figment = { version = "0.10.5", features = ["env"] } url = "2.2.2" -oauth2 = { path = "../oauth2" } +oauth2-types = { path = "../oauth2-types" } thiserror = "1.0.25" async-trait = "0.1.50" +tera = "1.10.0" diff --git a/matrix-authentication-service/src/handlers.rs b/matrix-authentication-service/src/handlers.rs index 7707cbb71..d3882f683 100644 --- a/matrix-authentication-service/src/handlers.rs +++ b/matrix-authentication-service/src/handlers.rs @@ -10,6 +10,7 @@ use crate::{ }; mod oauth2; +mod views; struct BrowserErrorHandler; @@ -84,8 +85,11 @@ impl Middleware for BrowserErrorHandler { } pub fn install(app: &mut Server) { + app.at("").get(self::views::index); + app.at(".well-known/openid-configuration") .get(self::oauth2::discovery); + app.at("oauth2/authorize") .with(BrowserErrorHandler) .get(self::oauth2::authorize); diff --git a/matrix-authentication-service/src/handlers/oauth2.rs b/matrix-authentication-service/src/handlers/oauth2.rs index da33ca39e..fedb77c81 100644 --- a/matrix-authentication-service/src/handlers/oauth2.rs +++ b/matrix-authentication-service/src/handlers/oauth2.rs @@ -1,6 +1,6 @@ use tide::{Body, Request, Response}; -use oauth2::{oidc::Metadata, requests::AuthorizationRequest}; +use oauth2_types::{oidc::Metadata, requests::AuthorizationRequest}; use crate::state::State; diff --git a/matrix-authentication-service/src/handlers/views.rs b/matrix-authentication-service/src/handlers/views.rs new file mode 100644 index 000000000..47a582cd1 --- /dev/null +++ b/matrix-authentication-service/src/handlers/views.rs @@ -0,0 +1,14 @@ +use tera::Context; +use tide::{Request, Response}; + +use crate::state::State; + +pub async fn index(req: Request) -> tide::Result { + let state = req.state(); + let content = state.templates().render("index.html", &Context::new())?; + let body = Response::builder(200) + .body(content) + .content_type("text/html") + .into(); + Ok(body) +} diff --git a/matrix-authentication-service/src/main.rs b/matrix-authentication-service/src/main.rs index cf729405a..a8653a4e7 100644 --- a/matrix-authentication-service/src/main.rs +++ b/matrix-authentication-service/src/main.rs @@ -1,3 +1,5 @@ +use tera::Tera; +use tracing::info; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Registry}; mod config; @@ -21,8 +23,14 @@ async fn main() -> tide::Result<()> { // Loading the config let config = Config::load()?; let address = config.listener.address.clone(); + + // Load and compile the templates + let path = format!("{}/templates/**/*.html", env!("CARGO_MANIFEST_DIR")); + info!(%path, "Loading templates"); + let templates = Tera::new(&path)?; + // Create the shared state - let state = State::new(config); + let state = State::new(config, templates); // Start the server let mut app = tide::with_state(state); diff --git a/matrix-authentication-service/src/state.rs b/matrix-authentication-service/src/state.rs index 77ea9aea1..7e2052e4f 100644 --- a/matrix-authentication-service/src/state.rs +++ b/matrix-authentication-service/src/state.rs @@ -1,5 +1,6 @@ use std::sync::Arc; +use tera::Tera; use url::Url; use crate::{config::Config, storage::Storage}; @@ -7,13 +8,15 @@ use crate::{config::Config, storage::Storage}; #[derive(Debug, Clone)] pub struct State { config: Arc, + templates: Arc, storage: Storage, } impl State { - pub fn new(config: Config) -> Self { + pub fn new(config: Config, templates: Tera) -> Self { Self { config: Arc::new(config), + templates: Arc::new(templates), storage: Default::default(), } } @@ -22,6 +25,10 @@ impl State { &self.storage } + pub fn templates(&self) -> &Tera { + &self.templates + } + fn base(&self) -> Url { self.config.oauth2.issuer.clone() } diff --git a/matrix-authentication-service/templates/base.html b/matrix-authentication-service/templates/base.html new file mode 100644 index 000000000..72024f755 --- /dev/null +++ b/matrix-authentication-service/templates/base.html @@ -0,0 +1,22 @@ + + + + + {% block title %}matrix-authentication-service{% endblock title %} + + + + + + + {% block content %}{% endblock content %} + + diff --git a/matrix-authentication-service/templates/index.html b/matrix-authentication-service/templates/index.html new file mode 100644 index 000000000..082c3f9e4 --- /dev/null +++ b/matrix-authentication-service/templates/index.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} + +{% block content %} +
+
+

Some content.

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eget dolor augue. Integer ut sagittis ipsum, non consectetur nunc. Aliquam sed auctor dolor. Maecenas non massa ultricies, ornare dui in, aliquet lacus. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas volutpat erat sit amet tortor vestibulum aliquet. Fusce ornare nibh vel ligula ullamcorper, gravida convallis nisi imperdiet. Sed ut erat tincidunt, sagittis ante a, facilisis est. Ut non justo vel metus hendrerit volutpat nec sit amet nulla. Proin id leo eu mi rhoncus porta. Quisque lacinia sodales augue id rhoncus. +

+
+
+{% endblock content %} diff --git a/oauth2/Cargo.toml b/oauth2-types/Cargo.toml similarity index 93% rename from oauth2/Cargo.toml rename to oauth2-types/Cargo.toml index c72a1cb2f..a37642c1b 100644 --- a/oauth2/Cargo.toml +++ b/oauth2-types/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "oauth2" +name = "oauth2-types" version = "0.1.0" authors = ["Quentin Gliech "] edition = "2018" diff --git a/oauth2/src/errors.rs b/oauth2-types/src/errors.rs similarity index 100% rename from oauth2/src/errors.rs rename to oauth2-types/src/errors.rs diff --git a/oauth2/src/lib.rs b/oauth2-types/src/lib.rs similarity index 100% rename from oauth2/src/lib.rs rename to oauth2-types/src/lib.rs diff --git a/oauth2/src/oidc.rs b/oauth2-types/src/oidc.rs similarity index 100% rename from oauth2/src/oidc.rs rename to oauth2-types/src/oidc.rs diff --git a/oauth2/src/requests.rs b/oauth2-types/src/requests.rs similarity index 100% rename from oauth2/src/requests.rs rename to oauth2-types/src/requests.rs diff --git a/oauth2/src/test_utils.rs b/oauth2-types/src/test_utils.rs similarity index 100% rename from oauth2/src/test_utils.rs rename to oauth2-types/src/test_utils.rs diff --git a/oauth2/src/types.rs b/oauth2-types/src/types.rs similarity index 100% rename from oauth2/src/types.rs rename to oauth2-types/src/types.rs