Serve and check cookies on login route

This commit is contained in:
selfhoster selfhoster 2023-08-22 19:29:40 +02:00
commit c73f132421
6 changed files with 46 additions and 11 deletions

View file

@ -1,19 +1,22 @@
use axum::{
extract::State,
routing::{get, post},
Router,
};
use tower_cookies::CookieManagerLayer;
use crate::state::RoutableAppState;
mod index;
mod login;
pub const COOKIE_NAME: &'static str = "yunohost.ssowat";
/// Build a router for the application, in a specific subpath eg `/yunohost/sso/`
pub fn router(subpath: Option<String>, state: RoutableAppState) -> Router {
let app = Router::new()
.route("/", get(index::route))
.route("/login/", post(login::route))
.layer(CookieManagerLayer::new())
.with_state(state);
if let Some(p) = subpath {
Router::new()