diff --git a/stalwart/docker-compose.yml b/stalwart/docker-compose.yml index a25025969..aa46169d7 100644 --- a/stalwart/docker-compose.yml +++ b/stalwart/docker-compose.yml @@ -8,8 +8,12 @@ services: PROXY_AUTH_ADD: "false" server: - image: stalwartlabs/stalwart:v1.1.1@sha256:5ebdf474b237161742fe4309396af4ae8797c938e8e6eb7e2d4837332c4f9851 + image: stalwartlabs/stalwart:v1.2.0@sha256:79ea09d25baad7e074d8df53db474571c5dc62621298e35e09e9cfd764333ed8 user: "1000:1000" + env_file: + # Created by pre-start, which runs after umbrelOS pulls images on install. + - path: ${APP_DATA_DIR}/data/role-permissions.env + required: false environment: - STALWART_RECOVERY_ADMIN=admin:${APP_PASSWORD} - STALWART_PUBLIC_URL=http://${DEVICE_DOMAIN_NAME}:8745 diff --git a/stalwart/hooks/post-start b/stalwart/hooks/post-start index 2044a25ab..a4378e930 100755 --- a/stalwart/hooks/post-start +++ b/stalwart/hooks/post-start @@ -20,6 +20,13 @@ for _ in {1..30}; do sleep 2 done +# pre-start asked Stalwart to add new permissions to its default roles on this +# start. Once the server is up that has happened, so don't ask again. +if docker exec stalwart_server_1 curl -fsS -o /dev/null http://127.0.0.1:8080/healthz/live 2>/dev/null \ + && grep -qs '^STALWART_UPDATE_ROLE_PERMISSIONS=true' "${APP_DATA_ROOT:-${APP_DIR}/data}/role-permissions.env"; then + touch "${APP_DATA_ROOT:-${APP_DIR}/data}/.role_permissions_updated" +fi + # Creating a client that already exists is rejected by the server and ignored here. for origin in "${origins[@]}"; do docker exec -i stalwart_server_1 curl -sS -o /dev/null -u "admin:${APP_PASSWORD}" \ @@ -33,3 +40,27 @@ for origin in "${origins[@]}"; do "scopes": {"full": true}}}}, "0"]]} JSON done + +# The WebUI requests only OpenID by default on Umbrel's HTTP origin. Without +# its explicit full scope, login succeeds but account management stays loading. +# Configure only the bundled WebUI with an empty scope list; keep custom apps +# and administrator-selected scopes unchanged. +applications="$(docker exec stalwart_server_1 curl -fsS -u "admin:${APP_PASSWORD}" \ + -H "Content-Type: application/json" --data \ + '{"using":["urn:ietf:params:jmap:core","urn:stalwart:jmap"],"methodCalls":[["x:Application/get",{},"0"]]}' \ + http://127.0.0.1:8080/jmap/)" || exit 0 +updates="$(printf '%s' "${applications}" | jq -c ' + [.methodResponses[] | select(.[0] == "x:Application/get") | .[1].list[] + | select(.resourceUrl == "https://github.com/stalwartlabs/webui/releases/download/v2/webui.zip") + | select(.urlPrefix["/admin"] == true and ((.oauthScopes // {}) | length) == 0) + | {key: .id, value: {oauthScopes: {"urn:stalwart:oauth:scope:full": true}}}] + | from_entries')" +if [[ "${updates}" != "{}" ]]; then + # Refresh application bundles through Stalwart's supported action so the + # new OAuth metadata is served immediately, without a second app restart. + jq -nc --argjson updates "${updates}" \ + '{using:["urn:ietf:params:jmap:core","urn:stalwart:jmap"],methodCalls:[["x:Application/set",{update:$updates},"0"],["x:Action/set",{create:{refresh:{"@type":"UpdateApps"}}},"1"]]}' \ + | docker exec -i stalwart_server_1 curl -fsS -u "admin:${APP_PASSWORD}" \ + -H "Content-Type: application/json" --data-binary @- http://127.0.0.1:8080/jmap/ \ + | jq -e '.methodResponses | length == 2 and all(.[]; (.[0] != "error") and ((.[1].notUpdated // {}) | length == 0) and ((.[1].notCreated // {}) | length == 0))' >/dev/null +fi diff --git a/stalwart/hooks/pre-start b/stalwart/hooks/pre-start index facb476f6..bccb1e31d 100755 --- a/stalwart/hooks/pre-start +++ b/stalwart/hooks/pre-start @@ -82,6 +82,20 @@ V1_TARGET_DIR="${LEGACY_ROOT}/server-v1" V1_ORIGINAL_DIR="${LEGACY_ROOT}/server-v0.16" V1_STATE_DIR="${LEGACY_ROOT}/migration-v1" +# Stalwart creates its default roles only on a new install, so on an upgraded +# server they miss permissions added by later releases (mail rules, sender +# lists, calendar settings, passkeys). Ask Stalwart to add them on one start +# only; post-start records that it ran, so a permission an administrator +# removes later is not added back on every restart. +ROLE_PERMISSIONS_ENV="${LEGACY_ROOT}/role-permissions.env" +ROLE_PERMISSIONS_DONE="${LEGACY_ROOT}/.role_permissions_updated" +mkdir -p "${LEGACY_ROOT}" +if [[ -f "${ROLE_PERMISSIONS_DONE}" ]]; then + : > "${ROLE_PERMISSIONS_ENV}" +else + echo "STALWART_UPDATE_ROLE_PERMISSIONS=true" > "${ROLE_PERMISSIONS_ENV}" +fi + v1_migrate() { docker run --rm --network none --user 1000:1000 \ -v "${FINAL_ETC_DIR}:/etc/stalwart" \ diff --git a/stalwart/umbrel-app.yml b/stalwart/umbrel-app.yml index d92cf12d9..240071212 100644 --- a/stalwart/umbrel-app.yml +++ b/stalwart/umbrel-app.yml @@ -3,7 +3,7 @@ id: stalwart name: Stalwart tagline: All-in-one Mail & Collaboration server category: files -version: "v1.1.1" +version: "v1.2.0" port: 8745 description: >- 📧 Stalwart is a fast, secure, and scalable open-source server for email, calendars, contacts, and file sharing, built in Rust for top-tier performance and safety. @@ -63,17 +63,22 @@ releaseNotes: >- If you are upgrading from v0.15.x or earlier, your data is first migrated to v0.16. Custom mail routing, listeners, spam rules and other unsupported configuration must be recreated, and custom administrator roles reassigned. See https://github.com/stalwartlabs/stalwart/blob/v0.16.27/UPGRADING/v0_16.md - Changes in v1.1.1 include: - - Masked email addresses are now available without an Enterprise license - - Security fixes for IMAP memory exhaustion, downloaded files, and tenant access controls - - More reliable mail synchronization, delivery, and S3 storage retries - - Fixes for calendar invitations, recurring events, and contact/file updates + Changes in v1.2.0 include: + - Exchange compatibility for Outlook, Apple Mail and ActiveSync clients (disabled by default) + - Server-side mail rules, blocked and safe sender lists, and read receipts + - Calendar working hours, shared availability, and resource accounts for rooms and equipment + - More reliable mail delivery, IMAP synchronization, calendar invitations, and search + - Security fixes for role permissions, active sessions, connection limits, and IPv6 auto-bans + - Fixes administrator sign-in on Umbrel's HTTP address - If you use Netcup for DNS, update your provider settings with a CloudDNS API key in the new apiKey field. The provider now supports CloudDNS domains only. + After upgrading, ensure the WebUI is v2.1.1 or newer. The standard user, group and administrator roles are updated automatically on the first start so mail rules, blocked and safe sender lists, calendar settings and passkeys work for everyone. If you have created your own roles, add the new permissions to them in the admin panel. - Full release notes: https://github.com/stalwartlabs/stalwart/releases/tag/v1.1.1 + If you use Netcup for DNS and are upgrading from before v1.1.1, update your provider settings with a CloudDNS API key in the apiKey field. The provider supports CloudDNS domains only. + + + Full release notes: https://github.com/stalwartlabs/stalwart/releases/tag/v1.2.0 dependencies: [] path: "/admin"