Ready to implement login page

This commit is contained in:
2022-03-30 10:29:10 +02:00
parent 70df96f286
commit 5bc4af399d
7 changed files with 118 additions and 4 deletions

View File

@ -3,4 +3,7 @@ pub const USERS_LIST_FILE: &str = "users.json";
/// Default built-in credentials
pub const DEFAULT_ADMIN_USERNAME: &str = "admin";
pub const DEFAULT_ADMIN_PASSWORD: &str = "admin";
pub const DEFAULT_ADMIN_PASSWORD: &str = "admin";
/// App name
pub const APP_NAME: &str = "Basic OIDC";

View File

@ -0,0 +1,15 @@
use actix_web::Responder;
use askama::Template;
use crate::constants::APP_NAME;
#[derive(Template)]
#[template(path = "login.html")]
struct LoginTemplate<'a> {
app_name: &'a str,
}
pub async fn login_route() -> impl Responder {
LoginTemplate { app_name: APP_NAME }.render().unwrap()
}

View File

@ -1 +1,2 @@
pub mod assets_controller;
pub mod assets_controller;
pub mod login_controller;

View File

@ -1,8 +1,10 @@
use actix_web::{App, HttpServer, web, get};
use actix_web::{App, get, HttpServer, web};
use actix_web::middleware::Logger;
use clap::Parser;
use basic_oidc::constants::{DEFAULT_ADMIN_PASSWORD, DEFAULT_ADMIN_USERNAME};
use basic_oidc::controllers::assets_controller::assets_route;
use basic_oidc::controllers::login_controller::login_route;
use basic_oidc::data::app_config::AppConfig;
use basic_oidc::data::entity_manager::EntityManager;
use basic_oidc::data::user::{hash_password, User};
@ -50,8 +52,10 @@ async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.wrap(Logger::default())
.service(health)
.route("/assets/{path:.*}", web::get().to(assets_route))
.route("/login", web::get().to(login_route))
})
.bind(config.listen_address)?
.run()