From 489c57a08ab4f7bf01aa22cd65afa75889ded9ae Mon Sep 17 00:00:00 2001 From: axelcouturier Date: Fri, 15 Nov 2024 11:23:14 +0100 Subject: [PATCH 1/2] add smtp configuration options in env file --- .env | 10 ++++++++- docker-compose/common/entrypoint_common | 11 ++++++++-- .../src/main/resources/application.yml | 22 +++++++++++-------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/.env b/.env index a849bca7bd..133b877308 100755 --- a/.env +++ b/.env @@ -11,8 +11,16 @@ SHANOIR_URL_HOST=shanoir-ng-nginx SHANOIR_VIEWER_OHIF_URL_SCHEME=https SHANOIR_VIEWER_OHIF_URL_HOST=viewer -# SMTP relay used by shanoir for all outgoing mail +# SMTP infos used by shanoir for all outgoing mail SHANOIR_SMTP_HOST=localhost +SHANOIR_SMTP_PORT=25 +SHANOIR_SMTP_AUTH=false +SHANOIR_SMTP_USERNAME=none +SHANOIR_SMTP_PASSWORD=none +SHANOIR_SMTP_STARTTLS_ENABLE=false +SHANOIR_SMTP_STARTTLS_REQUIRED=false +SHANOIR_SMTP_FROM=do-not-reply@inria.fr + # Name and e-mail address of the administrator (for signing outgoing e-mails) SHANOIR_ADMIN_EMAIL=shanoir.admin@inria.fr diff --git a/docker-compose/common/entrypoint_common b/docker-compose/common/entrypoint_common index b60a8232bb..9f5414a27b 100644 --- a/docker-compose/common/entrypoint_common +++ b/docker-compose/common/entrypoint_common @@ -71,9 +71,16 @@ require() SHANOIR_INSTANCE_NAME) match "$name" '^[^"\\]*$' ;; SHANOIR_INSTANCE_COLOR) match "$name" '^([A-Za-z]*|#[0-9a-fA-F]{3,6})$' ;; SHANOIR_KEYCLOAK_ADAPTER_MODE) match "$name" '^(login-required|check-sso)$' ;; - SHANOIR_ADMIN_EMAIL) ;; + SHANOIR_ADMIN_EMAIL) ;; SHANOIR_ADMIN_NAME) ;; - SHANOIR_SMTP_HOST) ;; + SHANOIR_SMTP_HOST) ;; + SHANOIR_SMTP_PORT) ;; + SHANOIR_SMTP_AUTH) match "$name" '^(true|false)$' ;; + SHANOIR_SMTP_USERNAME) ;; + SHANOIR_SMTP_PASSWORD) ;; + SHANOIR_SMTP_STARTTLS_ENABLE) match "$name" '^(true|false)$' ;; + SHANOIR_SMTP_STARTTLS_REQUIRED) match "$name" '^(true|false)$' ;; + SHANOIR_SMTP_FROM) ;; SHANOIR_CERTIFICATE_PEM_CRT) ;; SHANOIR_CERTIFICATE_PEM_KEY) ;; VIP_URL_SCHEME) match "$name" '^(http|https)$' ;; diff --git a/shanoir-ng-users/src/main/resources/application.yml b/shanoir-ng-users/src/main/resources/application.yml index 80a4327d3a..7887d6b846 100644 --- a/shanoir-ng-users/src/main/resources/application.yml +++ b/shanoir-ng-users/src/main/resources/application.yml @@ -1,12 +1,12 @@ # Shanoir NG - Import, manage and share neuroimaging data # Copyright (C) 2009-2019 Inria - https://www.inria.fr/ # Contact us on https://project.inria.fr/shanoir/ -# +# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # You should have received a copy of the GNU General Public License # along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html @@ -67,9 +67,15 @@ spring: store-type: none mail: host: ${SHANOIR_SMTP_HOST} - port: 25 + port: ${SHANOIR_SMTP_PORT} + username: ${SHANOIR_SMTP_USERNAME} + password: ${SHANOIR_SMTP_PASSWORD} properties: - mail.smtp.from: do-not-reply@inria.fr + mail.smtp.from: ${SHANOIR_SMTP_FROM} + mail.smtp.auth: ${SHANOIR_SMTP_AUTH} + mail.smtp.port: ${SHANOIR_SMTP_PORT} + mail.smtp.starttls.enable: ${SHANOIR_SMTP_STARTTLS_ENABLE} + mail.smtp.starttls.required: ${SHANOIR_SMTP_STARTTLS_REQUIRED} security: oauth2: resourceserver: @@ -77,7 +83,7 @@ spring: issuer-uri: ${SHANOIR_URL_SCHEME}://${SHANOIR_URL_HOST}/auth/realms/shanoir-ng springdoc: api-docs: - path: '/api-docs' + path: "/api-docs" enabled: true swagger-ui: url: /shanoir-ng/users/api-docs @@ -111,7 +117,6 @@ service-account: name: service-account-service-account email: ${VIP_SERVICE_EMAIL} - --- ###################################### # DO NOT COMMIT VALUES MODIFICATIONS # @@ -146,14 +151,13 @@ spring: # logging configuration logging: pattern: - file: '%d{yyyy-MM-dd_HH:mm:ss.SSS} %-5level [%mdc{username}] %logger{35} - %msg%n' + file: "%d{yyyy-MM-dd_HH:mm:ss.SSS} %-5level [%mdc{username}] %logger{35} - %msg%n" file: name: /var/log/shanoir-ng-logs/shanoir-ng-users.log level: org.springframework.web: DEBUG org.hibernate: ERROR - - + --- spring: config.activate.on-profile: test From 56743fdc38954b659ca853f4eade21ca090927b2 Mon Sep 17 00:00:00 2001 From: axelcouturier Date: Tue, 19 Nov 2024 15:21:38 +0100 Subject: [PATCH 2/2] added smtp env vars in keycloak config --- docker-compose/keycloak/cfg/shanoir-ng-realm.json | 8 ++++++-- docker-compose/keycloak/entrypoint | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docker-compose/keycloak/cfg/shanoir-ng-realm.json b/docker-compose/keycloak/cfg/shanoir-ng-realm.json index db9566b86b..08fbc2c6e0 100644 --- a/docker-compose/keycloak/cfg/shanoir-ng-realm.json +++ b/docker-compose/keycloak/cfg/shanoir-ng-realm.json @@ -1816,9 +1816,13 @@ }, "smtpServer": { "host": "SHANOIR_SMTP_HOST", + "auth": "SHANOIR_SMTP_AUTH", + "starttls": "SHANOIR_SMTP_STARTTLS_ENABLE", + "password": "SHANOIR_SMTP_PASSWORD", + "user": "SHANOIR_SMTP_USERNAME", "from": "SHANOIR_ADMIN_EMAIL", - "fromDisplayName": "SHANOIR_ADMIN_NAME", - "port": "25" + "fromDisplayName": "SHANOIR_SMTP_FROM", + "port": "SHANOIR_SMTP_PORT" }, "loginTheme": "shanoir-theme", "eventsEnabled": false, diff --git a/docker-compose/keycloak/entrypoint b/docker-compose/keycloak/entrypoint index 0cfbe99949..f4ed4bc7e9 100755 --- a/docker-compose/keycloak/entrypoint +++ b/docker-compose/keycloak/entrypoint @@ -8,6 +8,12 @@ require SHANOIR_ADMIN_EMAIL require SHANOIR_ADMIN_NAME optional SHANOIR_PREFIX require SHANOIR_SMTP_HOST +require SHANOIR_SMTP_PORT +require SHANOIR_SMTP_AUTH +require SHANOIR_SMTP_USERNAME +require SHANOIR_SMTP_PASSWORD +require SHANOIR_SMTP_STARTTLS_ENABLE +require SHANOIR_SMTP_FROM require SHANOIR_URL_SCHEME require SHANOIR_URL_HOST require SHANOIR_VIEWER_OHIF_URL_SCHEME @@ -17,6 +23,12 @@ mkdir -p /tmp/import sed " s/SHANOIR_ADMIN_NAME/$SHANOIR_ADMIN_NAME/g s/SHANOIR_ADMIN_EMAIL/$SHANOIR_ADMIN_EMAIL/g s/SHANOIR_SMTP_HOST/$SHANOIR_SMTP_HOST/g + s/SHANOIR_SMTP_PORT/$SHANOIR_SMTP_PORT/g + s/SHANOIR_SMTP_AUTH/$SHANOIR_SMTP_AUTH/g + s/SHANOIR_SMTP_USERNAME/$SHANOIR_SMTP_USERNAME/g + s/SHANOIR_SMTP_PASSWORD/$SHANOIR_SMTP_PASSWORD/g + s/SHANOIR_SMTP_STARTTLS_ENABLE/$SHANOIR_SMTP_STARTTLS_ENABLE/g + s/SHANOIR_SMTP_FROM/$SHANOIR_SMTP_FROM/g s/SHANOIR_URL_SCHEME/$SHANOIR_URL_SCHEME/g s/SHANOIR_URL_HOST/$SHANOIR_URL_HOST/g s/SHANOIR_VIEWER_OHIF_URL_SCHEME/$SHANOIR_VIEWER_OHIF_URL_SCHEME/g