From 2ce85290026df3774e793126dc3d87219b40e049 Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Mon, 14 Apr 2025 17:17:36 +0200 Subject: [PATCH] Some refactoring and app token management --- Cargo.lock | 1 + README.md | 6 +- .../public/templates/pages/calendar.html | 26 +++- .../frontend/public/templates/pages/user.html | 43 +++++-- crates/frontend/src/lib.rs | 73 +++++++++-- crates/frontend/src/nextcloud_login/mod.rs | 78 ++++++++++++ .../routes.rs} | 117 +++--------------- crates/store/Cargo.toml | 1 + crates/store/src/auth/mod.rs | 9 +- crates/store/src/auth/toml_user_store.rs | 23 +++- crates/store/src/auth/user.rs | 1 + crates/store/src/calendar/object.rs | 13 +- 12 files changed, 256 insertions(+), 135 deletions(-) create mode 100644 crates/frontend/src/nextcloud_login/mod.rs rename crates/frontend/src/{nextcloud_login.rs => nextcloud_login/routes.rs} (60%) diff --git a/Cargo.lock b/Cargo.lock index b9b71bd..9e9fb5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3164,6 +3164,7 @@ dependencies = [ "tokio", "toml", "tracing", + "uuid", ] [[package]] diff --git a/README.md b/README.md index bee79c5..7a158b6 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ docker run \ -p 4000:4000 \ -v YOUR_DATA_DIR:/var/lib/rustical/ \ -v YOUR_CONFIG_TOML:/etc/rustical/config.toml \ + -v YOUR_PRINCIPALS_TOML:/etc/rustical/principals.toml \ ghcr.io/lennart-k/rustical ``` @@ -77,7 +78,7 @@ id = "user" displayname = "User" password = "$argon2id$......." app_tokens = [ - {name = "Token", token = "$pbkdf2-sha256$........"}, + {id = "1", name = "Token", token = "$pbkdf2-sha256$........"}, ] memberships = ["group:amazing_group"] @@ -107,8 +108,9 @@ docker run -it --rm ghcr.io/lennart-k/rustical rustical pwhash The password is meant as a password you use to log in to the frontend. Since it's sensitive information, the secure but slow hash algorithm `argon2` is chosen. +If you've configured OpenID Connect you can also completely omit the password. -I recommend to generate random app tokens for each CalDAV/CardDAV client. +I recommend to generate random app tokens for each CalDAV/CardDAV client (which can also be done through the frontend). These can use the faster `pbkdf2` algorithm. ### WebDAV Push diff --git a/crates/frontend/public/templates/pages/calendar.html b/crates/frontend/public/templates/pages/calendar.html index c94f57b..455ba81 100644 --- a/crates/frontend/public/templates/pages/calendar.html +++ b/crates/frontend/public/templates/pages/calendar.html @@ -5,8 +5,30 @@ {% block content %} {% let name = calendar.displayname.to_owned().unwrap_or(calendar.id.to_owned()) %} -

{{ name }}

+

{{ calendar.principal }}/{{ name }}

{% if let Some(description) = calendar.description %}

{{ description }}

{% endif%} +{% if let Some(subscription_url) = calendar.subscription_url %} +

Subscription URL

+{{ subscription_url }} +{% endif %} + +

Components

+ + +

Timezone

+ +{% if let Some(timezone_id) = calendar.timezone_id %} +

{{ timezone_id }}

+{% endif %} +{% if let Some(timezone) = calendar.timezone %} +
{{ timezone }}
+{% endif %} + +
{{ calendar|json }}
-{% endblock %} +{%endblock %} diff --git a/crates/frontend/public/templates/pages/user.html b/crates/frontend/public/templates/pages/user.html index 480c41b..0e8794f 100644 --- a/crates/frontend/public/templates/pages/user.html +++ b/crates/frontend/public/templates/pages/user.html @@ -72,24 +72,47 @@ li.collection-list-item {

App tokens

-