mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 04:42:15 +00:00
completely rebuilt the auth implementation to support OIDC in the future
This commit is contained in:
21
src/app.rs
21
src/app.rs
@@ -2,15 +2,15 @@ use actix_web::body::MessageBody;
|
||||
use actix_web::dev::{ServiceFactory, ServiceRequest, ServiceResponse};
|
||||
use actix_web::middleware::{Logger, NormalizePath};
|
||||
use actix_web::{web, App};
|
||||
use rustical_auth::CheckAuthentication;
|
||||
use rustical_frontend::configure_frontend;
|
||||
use rustical_store::auth::{AuthenticationMiddleware, AuthenticationProvider};
|
||||
use rustical_store::CalendarStore;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
pub fn make_app<CS: CalendarStore + ?Sized, A: CheckAuthentication>(
|
||||
pub fn make_app<CS: CalendarStore + ?Sized, AP: AuthenticationProvider + 'static>(
|
||||
cal_store: Arc<RwLock<CS>>,
|
||||
auth: Arc<A>,
|
||||
auth_provider: Arc<AP>,
|
||||
) -> App<
|
||||
impl ServiceFactory<
|
||||
ServiceRequest,
|
||||
@@ -23,17 +23,14 @@ pub fn make_app<CS: CalendarStore + ?Sized, A: CheckAuthentication>(
|
||||
App::new()
|
||||
.wrap(Logger::new("[%s] %r"))
|
||||
.wrap(NormalizePath::trim())
|
||||
.wrap(AuthenticationMiddleware::new(auth_provider))
|
||||
.service(web::scope("/caldav").configure(|cfg| {
|
||||
rustical_caldav::configure_dav(
|
||||
cfg,
|
||||
"/caldav".to_string(),
|
||||
auth.clone(),
|
||||
cal_store.clone(),
|
||||
)
|
||||
}))
|
||||
.service(web::scope("/carddav").configure(|cfg| {
|
||||
rustical_carddav::configure_dav(cfg, "/carddav".to_string(), auth.clone())
|
||||
rustical_caldav::configure_dav(cfg, "/caldav".to_string(), cal_store.clone())
|
||||
}))
|
||||
.service(
|
||||
web::scope("/carddav")
|
||||
.configure(|cfg| rustical_carddav::configure_dav(cfg, "/carddav".to_string())),
|
||||
)
|
||||
.service(
|
||||
web::scope("/.well-known")
|
||||
.configure(|cfg| rustical_caldav::configure_well_known(cfg, "/caldav".to_string())), // .configure(|cfg| {
|
||||
|
||||
Reference in New Issue
Block a user