From be4d34228d8af51d3e1249446f72e857952a3b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 17 Aug 2023 17:26:59 +0200 Subject: [PATCH 1/8] Implement DKIM config for Nodemailer --- backend/.env.template | 3 +++ backend/src/config/index.ts | 3 +++ backend/src/middleware/helpers/email/sendMail.ts | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/backend/.env.template b/backend/.env.template index c1742ef93..d7a0945ec 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -10,6 +10,9 @@ SMTP_PORT= SMTP_IGNORE_TLS=true SMTP_USERNAME= SMTP_PASSWORD= +SMTP_DKIM_DOMAINNAME= +SMTP_DKIM_KEYSELECTOR= +SMTP_DKIM_PRIVATKEY= JWT_SECRET="b/&&7b78BF&fv/Vd" JWT_EXPIRES="2y" diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index b6098df11..1544e55a6 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -47,6 +47,9 @@ const smtp = { SMTP_SECURE: env.SMTP_SECURE === 'true', SMTP_USERNAME: env.SMTP_USERNAME, SMTP_PASSWORD: env.SMTP_PASSWORD, + SMTP_DKIM_DOMAINNAME: env.SMTP_DKIM_DOMAINNAME, + SMTP_DKIM_KEYSELECTOR: env.SMTP_DKIM_KEYSELECTOR, + SMTP_DKIM_PRIVATKEY: env.SMTP_DKIM_PRIVATKEY, } const neo4j = { diff --git a/backend/src/middleware/helpers/email/sendMail.ts b/backend/src/middleware/helpers/email/sendMail.ts index 359efc91e..c0e54e7f7 100644 --- a/backend/src/middleware/helpers/email/sendMail.ts +++ b/backend/src/middleware/helpers/email/sendMail.ts @@ -5,6 +5,8 @@ import { htmlToText } from 'nodemailer-html-to-text' const hasEmailConfig = CONFIG.SMTP_HOST && CONFIG.SMTP_PORT const hasAuthData = CONFIG.SMTP_USERNAME && CONFIG.SMTP_PASSWORD +const hasDKIMData = + CONFIG.SMTP_DKIM_DOMAINNAME && CONFIG.SMTP_DKIM_KEYSELECTOR && CONFIG.SMTP_DKIM_PRIVATKEY let sendMailCallback: any = async () => {} if (!hasEmailConfig) { @@ -44,6 +46,11 @@ if (!hasEmailConfig) { user: CONFIG.SMTP_USERNAME, pass: CONFIG.SMTP_PASSWORD, }, + dkim: hasDKIMData && { + domainName: CONFIG.SMTP_DKIM_DOMAINNAME, + keySelector: CONFIG.SMTP_DKIM_KEYSELECTOR, + privateKey: CONFIG.SMTP_DKIM_PRIVATKEY, + }, }) transporter.use( From 28665bd175236d2e00299fe895cd5901bfe7e499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 21 Aug 2023 12:33:39 +0200 Subject: [PATCH 2/8] Refine DKIM config for Nodemailer --- backend/.env.template | 7 ++++--- backend/src/config/index.ts | 9 ++++++--- backend/src/middleware/helpers/email/sendMail.ts | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/.env.template b/backend/.env.template index d7a0945ec..8361b8bd2 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -5,6 +5,10 @@ NEO4J_USERNAME=neo4j NEO4J_PASSWORD=letmein GRAPHQL_URI=http://localhost:4000 CLIENT_URI=http://localhost:3000 + +# EMail +EMAIL_SUPPORT="devops@ocelot.social" +EMAIL_DEFAULT_SENDER="devops@ocelot.social" SMTP_HOST= SMTP_PORT= SMTP_IGNORE_TLS=true @@ -31,7 +35,4 @@ AWS_ENDPOINT= AWS_REGION= AWS_BUCKET= -EMAIL_DEFAULT_SENDER="devops@ocelot.social" -EMAIL_SUPPORT="devops@ocelot.social" - CATEGORIES_ACTIVE=false diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 1544e55a6..d2d2926e9 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -40,6 +40,8 @@ const server = { JWT_EXPIRES: env.JWT_EXPIRES || '2y', } +const hasDKIMData = env.SMTP_DKIM_DOMAINNAME && env.SMTP_DKIM_KEYSELECTOR && env.SMTP_DKIM_PRIVATKEY + const smtp = { SMTP_HOST: env.SMTP_HOST, SMTP_PORT: env.SMTP_PORT, @@ -47,9 +49,10 @@ const smtp = { SMTP_SECURE: env.SMTP_SECURE === 'true', SMTP_USERNAME: env.SMTP_USERNAME, SMTP_PASSWORD: env.SMTP_PASSWORD, - SMTP_DKIM_DOMAINNAME: env.SMTP_DKIM_DOMAINNAME, - SMTP_DKIM_KEYSELECTOR: env.SMTP_DKIM_KEYSELECTOR, - SMTP_DKIM_PRIVATKEY: env.SMTP_DKIM_PRIVATKEY, + SMTP_DKIM_DOMAINNAME: hasDKIMData ? env.SMTP_DKIM_DOMAINNAME : undefined, + SMTP_DKIM_KEYSELECTOR: hasDKIMData ? env.SMTP_DKIM_KEYSELECTOR : undefined, + // PEM format: https://docs.progress.com/bundle/datadirect-hybrid-data-pipeline-installation-46/page/PEM-file-format.html + SMTP_DKIM_PRIVATKEY: hasDKIMData ? env.SMTP_DKIM_PRIVATKEY.replace(/\\n/g, '\n') : undefined, // replace all "\n" in .env string by real line break } const neo4j = { diff --git a/backend/src/middleware/helpers/email/sendMail.ts b/backend/src/middleware/helpers/email/sendMail.ts index c0e54e7f7..2e9551744 100644 --- a/backend/src/middleware/helpers/email/sendMail.ts +++ b/backend/src/middleware/helpers/email/sendMail.ts @@ -37,6 +37,8 @@ if (!hasEmailConfig) { } } else { sendMailCallback = async (templateArgs) => { + console.log('CONFIG.SMTP_DKIM_PRIVATKEY: "' + CONFIG.SMTP_DKIM_PRIVATKEY + '"') + console.log('templateArgs: ', templateArgs) const transporter = nodemailer.createTransport({ host: CONFIG.SMTP_HOST, port: CONFIG.SMTP_PORT, From f866f37bc85ce77a694e7c7f5ec85d90e632cbc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 21 Aug 2023 13:44:17 +0200 Subject: [PATCH 3/8] Add 'SMTP_SECURE' to '.env.template' of backend --- backend/.env.template | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/.env.template b/backend/.env.template index 8361b8bd2..d398c2265 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -14,6 +14,7 @@ SMTP_PORT= SMTP_IGNORE_TLS=true SMTP_USERNAME= SMTP_PASSWORD= +SMTP_SECURE="false" # true for 465, false for other ports SMTP_DKIM_DOMAINNAME= SMTP_DKIM_KEYSELECTOR= SMTP_DKIM_PRIVATKEY= From cd206c238adb7eb5db46a815c9bfcde4ea3aec46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 21 Aug 2023 13:44:29 +0200 Subject: [PATCH 4/8] Cleanup --- backend/src/middleware/helpers/email/sendMail.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/src/middleware/helpers/email/sendMail.ts b/backend/src/middleware/helpers/email/sendMail.ts index 2e9551744..c0e54e7f7 100644 --- a/backend/src/middleware/helpers/email/sendMail.ts +++ b/backend/src/middleware/helpers/email/sendMail.ts @@ -37,8 +37,6 @@ if (!hasEmailConfig) { } } else { sendMailCallback = async (templateArgs) => { - console.log('CONFIG.SMTP_DKIM_PRIVATKEY: "' + CONFIG.SMTP_DKIM_PRIVATKEY + '"') - console.log('templateArgs: ', templateArgs) const transporter = nodemailer.createTransport({ host: CONFIG.SMTP_HOST, port: CONFIG.SMTP_PORT, From 9f5d32e527151854f1888614c59e0aa5f2b504d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 22 Aug 2023 14:20:10 +0200 Subject: [PATCH 5/8] Write documentation for DKIM e-mail setting --- README.md | 2 + SUMMARY.md | 2 +- deployment/README.md | 9 +++-- deployment/deployment-values.md | 38 +++++++++++++++++++ .../{README.deployment.md => deployment.md} | 0 5 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 deployment/deployment-values.md rename deployment/{README.deployment.md => deployment.md} (100%) diff --git a/README.md b/README.md index 06e8d4929..2062865dd 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,11 @@ [ocelot.social](https://ocelot.social) is free and open source software program code to run social networks. Its development is supported by a community of programmers and interested network operators. +

ocelot.social

+ Our goal is to enable people to participate fairly and equally in online social networks. The equality of opportunity applies both to the fundamental equality of all people and to the possibility of letting their diverse voices be heard. diff --git a/SUMMARY.md b/SUMMARY.md index f848633d5..453a809b4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -16,7 +16,7 @@ * [Frontend tests](webapp/testing.md) * [Backend tests](backend/testing.md) * [Docker More Closely](DOCKER_MORE_CLOSELY.md) -* [Deployment](https://github.com/Ocelot-Social-Community/Ocelot-Social-Deploy-Rebranding/blob/master/deployment/README.md) +* [Deployment](deployment/README.md) * [Contributing](CONTRIBUTING.md) * [Feature Specification](cypress/features.md) * [Code of conduct](CODE_OF_CONDUCT.md) diff --git a/deployment/README.md b/deployment/README.md index 030eb8a44..93d3fb86c 100644 --- a/deployment/README.md +++ b/deployment/README.md @@ -6,11 +6,11 @@ [![Open Source Helpers](https://www.codetriage.com/ocelot-social-community/ocelot-social-deploy-rebranding/badges/users.svg)](https://www.codetriage.com/ocelot-social-community/ocelot-social-deploy-rebranding) This repository is an in use template to rebrand, configure, and deploy [ocelot.social](https://github.com/Ocelot-Social-Community/Ocelot-Social) networks. -The forked original repository is [Ocelot-Social-Deploy-Rebranding](https://github.com/Ocelot-Social-Community/Ocelot-Social-Deploy-Rebranding). +The forked original repository is [stage.ocelot.social](https://github.com/Ocelot-Social-Community/stage.ocelot.social).

- Ocelot-Social + ocelot.social

@@ -47,7 +47,8 @@ Since all deployment methods described here depend on [Docker](https://docker.co The next step is: -- [Configure And Branding](/branding/README.md) +- [Set Environment Variables and Configurations](./deployment-values.md) +- [Configure And Branding](./configurations/stage.ocelot.social/branding/README.md) ### Optional: Locally Testing Configuration And Branding @@ -99,7 +100,7 @@ See the login details and browser addresses above. ### Deployment -Afterwards you can [deploy](/deployment/README.md) it on your server: +Afterwards you can [deploy](/deployment/deployment.md) it on your server: - [Kubernetes with Helm](/deployment/kubernetes/README.md) diff --git a/deployment/deployment-values.md b/deployment/deployment-values.md new file mode 100644 index 000000000..300a056dd --- /dev/null +++ b/deployment/deployment-values.md @@ -0,0 +1,38 @@ +# Deployment Values + +For each deployment, you need to set the environment variables and configurations. +Here is some specific information on how to set the values. + +## E-Mails + +You need to set environment variables to send registration and invitation information or notifications to users, for example. + +### SPF and DKIM + +More and more e-mail providers require settings for authorization and verification of e-mail senders. + +### SPF + +Sometimes it is enough to create an SPF record in your DNS. + +### DKIM + +However, if you need DKIM authorization and verification, you must set the appropriate environment variables: + +```bash +SMTP_DKIM_DOMAINNAME= +SMTP_DKIM_KEYSELECTOR=2017 +SMTP_DKIM_PRIVATKEY="-----BEGIN RSA PRIVATE KEY-----\n\n-----END RSA PRIVATE KEY-----\n" +``` + +You can find out how DKIM works here: + + + +To create the private and public DKIM key, see here: + + + +Information about the required PEM format can be found here: + + diff --git a/deployment/README.deployment.md b/deployment/deployment.md similarity index 100% rename from deployment/README.deployment.md rename to deployment/deployment.md From c6b1d663c17b8d9082e477f1de4f4b3f074dec2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 22 Aug 2023 14:55:47 +0200 Subject: [PATCH 6/8] Shorten code of DKIM config for Nodemailer to the solution used otherwise in code --- backend/src/config/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index d2d2926e9..9f03622a5 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -49,10 +49,10 @@ const smtp = { SMTP_SECURE: env.SMTP_SECURE === 'true', SMTP_USERNAME: env.SMTP_USERNAME, SMTP_PASSWORD: env.SMTP_PASSWORD, - SMTP_DKIM_DOMAINNAME: hasDKIMData ? env.SMTP_DKIM_DOMAINNAME : undefined, - SMTP_DKIM_KEYSELECTOR: hasDKIMData ? env.SMTP_DKIM_KEYSELECTOR : undefined, + SMTP_DKIM_DOMAINNAME: hasDKIMData && env.SMTP_DKIM_DOMAINNAME, + SMTP_DKIM_KEYSELECTOR: hasDKIMData && env.SMTP_DKIM_KEYSELECTOR, // PEM format: https://docs.progress.com/bundle/datadirect-hybrid-data-pipeline-installation-46/page/PEM-file-format.html - SMTP_DKIM_PRIVATKEY: hasDKIMData ? env.SMTP_DKIM_PRIVATKEY.replace(/\\n/g, '\n') : undefined, // replace all "\n" in .env string by real line break + SMTP_DKIM_PRIVATKEY: hasDKIMData && env.SMTP_DKIM_PRIVATKEY.replace(/\\n/g, '\n'), // replace all "\n" in .env string by real line break } const neo4j = { From a3a6719d0096f899e30464b4dbadc152972787bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 23 Aug 2023 14:58:40 +0200 Subject: [PATCH 7/8] Add new configuration for DKIM to 'TODO-next-update.md' --- deployment/TODO-next-update.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/deployment/TODO-next-update.md b/deployment/TODO-next-update.md index 8e30d1f47..452b95164 100644 --- a/deployment/TODO-next-update.md +++ b/deployment/TODO-next-update.md @@ -1,6 +1,13 @@ # Todo For Next Update -When you overtake this deploy and rebrand repo to your network you have to recognize the following changes and doings: +When you introduce a new version and branding and deploy it on your network, you need to consider the following changes and actions: + +## Version >= 3.3.0 with 'ocelotDockerVersionTag' 3.3.0-XXX + +- We have the new option to configure DKIM for sent e-mails, see [here](deployment.md): + - `SMTP_DKIM_DOMAINNAME=` + - `SMTP_DKIM_KEYSELECTOR=` + - `SMTP_DKIM_PRIVATKEY=` ## Version >= 2.7.0 with 'ocelotDockerVersionTag' 2.7.0-470 From bec27daea78816421d317136ad6c16d18e3df3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 23 Aug 2023 15:02:15 +0200 Subject: [PATCH 8/8] Refine new configuration for DKIM to 'TODO-next-update.md' --- deployment/TODO-next-update.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/TODO-next-update.md b/deployment/TODO-next-update.md index 452b95164..4470efa14 100644 --- a/deployment/TODO-next-update.md +++ b/deployment/TODO-next-update.md @@ -4,7 +4,7 @@ When you introduce a new version and branding and deploy it on your network, you ## Version >= 3.3.0 with 'ocelotDockerVersionTag' 3.3.0-XXX -- We have the new option to configure DKIM for sent e-mails, see [here](deployment.md): +- We have the new option to configure DKIM for sent e-mails in environment variables (`.env` or `values.yaml`), see [here](deployment.md): - `SMTP_DKIM_DOMAINNAME=` - `SMTP_DKIM_KEYSELECTOR=` - `SMTP_DKIM_PRIVATKEY=`