diff --git a/Cargo.lock b/Cargo.lock index dc38ed2..4605f96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3037,6 +3037,7 @@ dependencies = [ "rustical_dav", "rustical_dav_push", "rustical_frontend", + "rustical_oidc", "rustical_store", "rustical_store_sqlite", "serde", @@ -3157,10 +3158,9 @@ dependencies = [ "futures-core", "hex", "mime_guess", - "openidconnect", "rand 0.8.5", - "reqwest", "rust-embed", + "rustical_oidc", "rustical_store", "serde", "thiserror 2.0.12", @@ -3170,6 +3170,19 @@ dependencies = [ "uuid", ] +[[package]] +name = "rustical_oidc" +version = "0.1.0" +dependencies = [ + "actix-session", + "actix-web", + "openidconnect", + "reqwest", + "rustical_store", + "serde", + "thiserror 2.0.12", +] + [[package]] name = "rustical_store" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 19a31b4..04d275b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,6 +95,7 @@ rustical_caldav = { path = "./crates/caldav/" } rustical_carddav = { path = "./crates/carddav/" } rustical_frontend = { path = "./crates/frontend/" } rustical_xml = { path = "./crates/xml/" } +rustical_oidc = { path = "./crates/oidc/" } chrono-tz = "0.10" chrono-humanize = "0.2" rand = "0.8" @@ -157,4 +158,5 @@ password-hash.workspace = true reqwest.workspace = true rustical_dav.workspace = true rustical_dav_push.workspace = true +rustical_oidc.workspace = true quick-xml.workspace = true diff --git a/crates/frontend/Cargo.toml b/crates/frontend/Cargo.toml index 93be0c6..2dcf1d3 100644 --- a/crates/frontend/Cargo.toml +++ b/crates/frontend/Cargo.toml @@ -7,7 +7,6 @@ repository.workspace = true publish = false [dependencies] -openidconnect.workspace = true askama.workspace = true askama_web.workspace = true actix-session = { workspace = true } @@ -20,10 +19,10 @@ rust-embed.workspace = true futures-core.workspace = true hex.workspace = true mime_guess.workspace = true -reqwest.workspace = true rand.workspace = true chrono.workspace = true chrono-humanize.workspace = true uuid.workspace = true url.workspace = true tracing.workspace = true +rustical_oidc.workspace = true diff --git a/crates/frontend/src/config.rs b/crates/frontend/src/config.rs index 8cfb66b..1c73f92 100644 --- a/crates/frontend/src/config.rs +++ b/crates/frontend/src/config.rs @@ -1,4 +1,3 @@ -pub use crate::oidc::OidcConfig; use serde::{Deserialize, Serialize}; fn default_true() -> bool { diff --git a/crates/frontend/src/lib.rs b/crates/frontend/src/lib.rs index 13aef2f..4fe556f 100644 --- a/crates/frontend/src/lib.rs +++ b/crates/frontend/src/lib.rs @@ -14,13 +14,13 @@ use actix_web::{ use askama::Template; use askama_web::WebTemplate; use assets::{Assets, EmbedService}; -use oidc::configure_oidc; use rand::{Rng, distributions::Alphanumeric}; use routes::{ addressbook::{route_addressbook, route_addressbook_restore}, calendar::{route_calendar, route_calendar_restore}, login::{route_get_login, route_post_login, route_post_logout}, }; +use rustical_oidc::{OidcConfig, configure_oidc}; use rustical_store::{ Addressbook, AddressbookStore, Calendar, CalendarStore, auth::{AuthenticationMiddleware, AuthenticationProvider, User}, @@ -31,13 +31,12 @@ use std::sync::Arc; mod assets; mod config; pub mod nextcloud_login; -mod oidc; mod routes; pub const ROUTE_NAME_HOME: &str = "frontend_home"; pub const ROUTE_USER_NAMED: &str = "frontend_user_named"; -pub use config::{FrontendConfig, OidcConfig}; +pub use config::FrontendConfig; pub fn generate_app_token() -> String { rand::thread_rng() diff --git a/crates/frontend/src/routes/login.rs b/crates/frontend/src/routes/login.rs index 74b0fee..d708732 100644 --- a/crates/frontend/src/routes/login.rs +++ b/crates/frontend/src/routes/login.rs @@ -1,4 +1,4 @@ -use crate::{FrontendConfig, OidcConfig, oidc::ROUTE_NAME_OIDC_LOGIN}; +use crate::{FrontendConfig, OidcConfig}; use actix_session::Session; use actix_web::{ HttpRequest, HttpResponse, Responder, @@ -7,6 +7,7 @@ use actix_web::{ }; use askama::Template; use askama_web::WebTemplate; +use rustical_oidc::ROUTE_NAME_OIDC_LOGIN; use rustical_store::auth::AuthenticationProvider; use serde::Deserialize; use tracing::instrument; diff --git a/crates/oidc/Cargo.toml b/crates/oidc/Cargo.toml new file mode 100644 index 0000000..d5773f0 --- /dev/null +++ b/crates/oidc/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "rustical_oidc" +version.workspace = true +edition.workspace = true +description.workspace = true +repository.workspace = true + +[dependencies] +openidconnect.workspace = true +serde = { workspace = true } +reqwest.workspace = true +# TODO: Remove this dependency +rustical_store = { workspace = true } +actix-web = { workspace = true } +actix-session = { workspace = true } +thiserror = { workspace = true } diff --git a/crates/frontend/src/oidc/config.rs b/crates/oidc/src/config.rs similarity index 100% rename from crates/frontend/src/oidc/config.rs rename to crates/oidc/src/config.rs diff --git a/crates/frontend/src/oidc/error.rs b/crates/oidc/src/error.rs similarity index 100% rename from crates/frontend/src/oidc/error.rs rename to crates/oidc/src/error.rs diff --git a/crates/frontend/src/oidc/mod.rs b/crates/oidc/src/lib.rs similarity index 100% rename from crates/frontend/src/oidc/mod.rs rename to crates/oidc/src/lib.rs diff --git a/src/app.rs b/src/app.rs index abc16ef..ef229ec 100644 --- a/src/app.rs +++ b/src/app.rs @@ -5,7 +5,8 @@ use actix_web::{App, web}; use rustical_caldav::caldav_service; use rustical_carddav::carddav_service; use rustical_frontend::nextcloud_login::{NextcloudFlows, configure_nextcloud_login}; -use rustical_frontend::{FrontendConfig, OidcConfig, configure_frontend}; +use rustical_frontend::{FrontendConfig, configure_frontend}; +use rustical_oidc::OidcConfig; use rustical_store::auth::AuthenticationProvider; use rustical_store::{AddressbookStore, CalendarStore, SubscriptionStore}; use std::sync::Arc; diff --git a/src/config.rs b/src/config.rs index 3a1c306..55919b9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,5 @@ -use rustical_frontend::{FrontendConfig, OidcConfig}; +use rustical_frontend::FrontendConfig; +use rustical_oidc::OidcConfig; use rustical_store::auth::TomlUserStoreConfig; use serde::{Deserialize, Serialize};