Add middleware to require authentication for some routes
All checks were successful
Push Workflows / rustfmt (push) Successful in 14s
Push Workflows / tailwind-build (push) Successful in 13s
Push Workflows / clippy (push) Successful in 25s
Push Workflows / test (push) Successful in 34s
Push Workflows / docs (push) Successful in 31s
Push Workflows / build (push) Successful in 59s
Push Workflows / nix-build (push) Successful in 5m27s
All checks were successful
Push Workflows / rustfmt (push) Successful in 14s
Push Workflows / tailwind-build (push) Successful in 13s
Push Workflows / clippy (push) Successful in 25s
Push Workflows / test (push) Successful in 34s
Push Workflows / docs (push) Successful in 31s
Push Workflows / build (push) Successful in 59s
Push Workflows / nix-build (push) Successful in 5m27s
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
use dioxus::{fullstack::axum::Router, server::axum::Extension};
|
||||
use dioxus::{
|
||||
fullstack::axum::{Router, middleware::from_fn},
|
||||
server::axum::Extension,
|
||||
};
|
||||
|
||||
use crate::App;
|
||||
use crate::server::{auth::build_auth_layer, config, database, key_val_store};
|
||||
use crate::server::{
|
||||
auth::build_auth_layer, config, database, key_val_store,
|
||||
require_auth_mw::require_auth_middleware,
|
||||
};
|
||||
use crate::util::error::{Contextualize, Error, Result};
|
||||
|
||||
pub fn main() -> Result<std::convert::Infallible> {
|
||||
@@ -31,6 +37,7 @@ async fn router_setup() -> Result<Router> {
|
||||
let auth_layer = build_auth_layer(db_pool.clone(), key_val_pool);
|
||||
|
||||
let router = dioxus::server::router(App)
|
||||
.layer(from_fn(require_auth_middleware))
|
||||
.layer(Extension(config))
|
||||
.layer(Extension(db_pool))
|
||||
.layer(auth_layer);
|
||||
|
||||
Reference in New Issue
Block a user