diff --git a/Cargo.toml b/Cargo.toml index d263da0..415b103 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] rocket = { git = "https://github.com/SergioBenitez/Rocket.git", branch="master" } -rocket_contrib = { git = "https://github.com/SergioBenitez/Rocket.git", branch="master" } +rocket_contrib = { git = "https://github.com/SergioBenitez/Rocket.git", branch="master", features = ["tera_templates"] } futures = "0.1.21" ldap3 = "0.6" tokio = "0.1.0" diff --git a/src/main.rs b/src/main.rs index 886f24c..6a0fd8c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,7 @@ use openssl::rsa::Rsa; use ldap3::{ LdapConn, Scope, SearchEntry }; use rocket::request::Form; use rocket_contrib::json::Json; +use rocket_contrib::templates::Template; #[derive(Debug)] struct BasicAuthentication { @@ -174,8 +175,11 @@ fn oidc_config() -> Json { } #[get("/")] -fn hello() -> &'static str { - "Hello!" +fn hello() -> Template { + let config = OidcConfig { + jwks_uri: "https://auth.xeen.dev/oauth2/keys".to_string(), + }; + Template::render("hello", &config) } fn routes() -> Vec { @@ -190,5 +194,8 @@ fn routes() -> Vec { fn main() { env_logger::init(); - rocket::ignite().mount("/", routes()).launch(); + rocket::ignite() + .attach(Template::fairing()) + .mount("/", routes()) + .launch(); } diff --git a/templates/base.html.tera b/templates/base.html.tera new file mode 100644 index 0000000..59a859a --- /dev/null +++ b/templates/base.html.tera @@ -0,0 +1,11 @@ + + + + Auth + + + {% block content %} +

Hi!

+ {% endblock content %} + + diff --git a/templates/hello.html.tera b/templates/hello.html.tera new file mode 100644 index 0000000..c33993f --- /dev/null +++ b/templates/hello.html.tera @@ -0,0 +1,5 @@ +{% extends "base" %} + +{% block content %} +

Hello!

+{% endblock content %}