From df3a9cb0b47bd4e73688713c5a7a86b72097a76c Mon Sep 17 00:00:00 2001 From: Craig Huther Date: Mon, 28 Sep 2020 14:41:08 -0400 Subject: [PATCH 1/4] Added EMAIL_FROM_ADDRESS environment variable. Default is no-reply@orcpub.com --- README.md | 4 +++- docker-compose-build.yaml | 2 ++ docker-compose.yaml | 2 ++ src/clj/orcpub/email.clj | 6 +++--- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 165589815..18798b888 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ EMAIL_SERVER_URL: '' # DNS name of your smtp server EMAIL_ACCESS_KEY: '' # User for the mail server EMAIL_SECRET_KEY: '' # Password for the user EMAIL_SERVER_PORT: 587 # Mail server port +EMAIL_FROM_ADDRESS: 'no-reply@orcpub.com' # Email address to send from EMAIL_SSL: 'false' # Should SSL be used? Gmail requires this. EMAIL_TLS: 'false' # Should TLS be used? DATOMIC_URL: datomic:free://datomic:4334/orcpub?password=yourpassword # Url for the database @@ -193,6 +194,7 @@ EMAIL_SERVER_URL: '' # Url to a smtp server EMAIL_ACCESS_KEY: '' # User for the mail server EMAIL_SECRET_KEY: '' # Password for the user EMAIL_SERVER_PORT: 587 # Mail server port +EMAIL_FROM_ADDRESS: 'no-reply@orcpub.com' # Email address to send from EMAIL_SSL: 'false' # Should SSL be used? Gmail requires this. DATOMIC_URL: datomic:free://datomic:4334/orcpub?password=yourpassword # Url for the database ADMIN_PASSWORD: supersecretpassword @@ -462,4 +464,4 @@ The use of this tool is meant for use for your own use and your own content. It Larry Christensen original author of [Orcpub2](https://github.com/larrychristensen/orcpub) ## License -[EPL-2.0](LICENSE) \ No newline at end of file +[EPL-2.0](LICENSE) diff --git a/docker-compose-build.yaml b/docker-compose-build.yaml index b678e1347..4c968121e 100644 --- a/docker-compose-build.yaml +++ b/docker-compose-build.yaml @@ -11,6 +11,8 @@ services: EMAIL_ACCESS_KEY: '' EMAIL_SECRET_KEY: '' EMAIL_SERVER_PORT: 587 + # Email address to send from + EMAIL_FROM_ADDRESS: 'no-reply@orcpub.com' # Email address to send errors to EMAIL_ERRORS_TO: '' EMAIL_SSL: 'TRUE' diff --git a/docker-compose.yaml b/docker-compose.yaml index 24f207616..a8c53ff76 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,6 +9,8 @@ services: EMAIL_ACCESS_KEY: '' EMAIL_SECRET_KEY: '' EMAIL_SERVER_PORT: 587 + # Email address to send from + EMAIL_FROM_ADDRESS: 'no-reply@orcpub.com' # Email address to send errors to EMAIL_ERRORS_TO: '' EMAIL_SSL: 'FALSE' diff --git a/src/clj/orcpub/email.clj b/src/clj/orcpub/email.clj index 258d48c47..4d29c7b1b 100644 --- a/src/clj/orcpub/email.clj +++ b/src/clj/orcpub/email.clj @@ -37,7 +37,7 @@ (defn send-verification-email [base-url {:keys [email username first-and-last-name]} verification-key] (postal/send-message (email-cfg) - {:from "OrcPub Team " + {:from (str "OrcPub Team <" (environ/env :email-from-address) ">") :to email :subject "OrcPub Email Verification" :body (verification-email @@ -70,7 +70,7 @@ (defn send-reset-email [base-url {:keys [email username first-and-last-name]} reset-key] (postal/send-message (email-cfg) - {:from "OrcPub Team " + {:from (str "OrcPub Team <" (environ/env :email-from-address) ">") :to email :subject "OrcPub Password Reset" :body (reset-password-email @@ -80,7 +80,7 @@ (defn send-error-email [context exception] (if (not-empty (environ/env :email-errors-to)) (postal/send-message (email-cfg) - {:from (str "OrcPub Errors <" (environ/env :email-errors-to) ">") + {:from (str "OrcPub Errors <" (environ/env :email-from-address) ">") :to (str (environ/env :email-errors-to)) :subject "Exception" :body [{:type "text/plain" From 29f9ff4e34216a992c021da7df6b7d7d45c38bc9 Mon Sep 17 00:00:00 2001 From: Craig Huther Date: Tue, 29 Sep 2020 11:55:51 -0400 Subject: [PATCH 2/4] FROM_EMAIL_ADDRESS now defaults to 'no-reply@orcpub.com' --- README.md | 4 ++-- docker-compose-build.yaml | 4 ++-- docker-compose.yaml | 4 ++-- src/clj/orcpub/email.clj | 9 ++++++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 18798b888..ff8475c29 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ EMAIL_SERVER_URL: '' # DNS name of your smtp server EMAIL_ACCESS_KEY: '' # User for the mail server EMAIL_SECRET_KEY: '' # Password for the user EMAIL_SERVER_PORT: 587 # Mail server port -EMAIL_FROM_ADDRESS: 'no-reply@orcpub.com' # Email address to send from +EMAIL_FROM_ADDRESS: '' # Email address to send from, will default to 'no-reply@orcpub.com' EMAIL_SSL: 'false' # Should SSL be used? Gmail requires this. EMAIL_TLS: 'false' # Should TLS be used? DATOMIC_URL: datomic:free://datomic:4334/orcpub?password=yourpassword # Url for the database @@ -194,7 +194,7 @@ EMAIL_SERVER_URL: '' # Url to a smtp server EMAIL_ACCESS_KEY: '' # User for the mail server EMAIL_SECRET_KEY: '' # Password for the user EMAIL_SERVER_PORT: 587 # Mail server port -EMAIL_FROM_ADDRESS: 'no-reply@orcpub.com' # Email address to send from +EMAIL_FROM_ADDRESS: '' # Email address to send from, will default to 'no-reply@orcpub.com' EMAIL_SSL: 'false' # Should SSL be used? Gmail requires this. DATOMIC_URL: datomic:free://datomic:4334/orcpub?password=yourpassword # Url for the database ADMIN_PASSWORD: supersecretpassword diff --git a/docker-compose-build.yaml b/docker-compose-build.yaml index 4c968121e..69cb33960 100644 --- a/docker-compose-build.yaml +++ b/docker-compose-build.yaml @@ -11,8 +11,8 @@ services: EMAIL_ACCESS_KEY: '' EMAIL_SECRET_KEY: '' EMAIL_SERVER_PORT: 587 - # Email address to send from - EMAIL_FROM_ADDRESS: 'no-reply@orcpub.com' + # Email address to send from, will default to 'no-reply@orcpub.com' + EMAIL_FROM_ADDRESS: '' # Email address to send errors to EMAIL_ERRORS_TO: '' EMAIL_SSL: 'TRUE' diff --git a/docker-compose.yaml b/docker-compose.yaml index a8c53ff76..e743171a4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,8 +9,8 @@ services: EMAIL_ACCESS_KEY: '' EMAIL_SECRET_KEY: '' EMAIL_SERVER_PORT: 587 - # Email address to send from - EMAIL_FROM_ADDRESS: 'no-reply@orcpub.com' + # Email address to send from, will default to 'no-reply@orcpub.com' + EMAIL_FROM_ADDRESS: '' # Email address to send errors to EMAIL_ERRORS_TO: '' EMAIL_SSL: 'FALSE' diff --git a/src/clj/orcpub/email.clj b/src/clj/orcpub/email.clj index 4d29c7b1b..257accb96 100644 --- a/src/clj/orcpub/email.clj +++ b/src/clj/orcpub/email.clj @@ -35,9 +35,12 @@ :tls (or (str/to-bool (environ/env :email-tls)) nil) }) +(defn emailfrom [] + (if (not (clojure.string/blank? (environ/env :email-from-address))) (environ/env :email-from-address) (str "no-reply@orcpub.com"))) + (defn send-verification-email [base-url {:keys [email username first-and-last-name]} verification-key] (postal/send-message (email-cfg) - {:from (str "OrcPub Team <" (environ/env :email-from-address) ">") + {:from (str "OrcPub Team <" (emailfrom) ">") :to email :subject "OrcPub Email Verification" :body (verification-email @@ -70,7 +73,7 @@ (defn send-reset-email [base-url {:keys [email username first-and-last-name]} reset-key] (postal/send-message (email-cfg) - {:from (str "OrcPub Team <" (environ/env :email-from-address) ">") + {:from (str "OrcPub Team <" (emailfrom) ">") :to email :subject "OrcPub Password Reset" :body (reset-password-email @@ -80,7 +83,7 @@ (defn send-error-email [context exception] (if (not-empty (environ/env :email-errors-to)) (postal/send-message (email-cfg) - {:from (str "OrcPub Errors <" (environ/env :email-from-address) ">") + {:from (str "OrcPub Errors <" (emailfrom) ">") :to (str (environ/env :email-errors-to)) :subject "Exception" :body [{:type "text/plain" From 1107eb9b6df9f3b307b0a5d1195b99f92095d73d Mon Sep 17 00:00:00 2001 From: Craig Huther Date: Tue, 29 Sep 2020 11:58:33 -0400 Subject: [PATCH 3/4] Removed in-line namespace reference to clojure.string and moved to require --- src/clj/orcpub/email.clj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/clj/orcpub/email.clj b/src/clj/orcpub/email.clj index 257accb96..8af50a0ea 100644 --- a/src/clj/orcpub/email.clj +++ b/src/clj/orcpub/email.clj @@ -3,6 +3,7 @@ [postal.core :as postal] [environ.core :as environ] [clojure.pprint :as pprint] + [clojure.string :as s] [orcpub.route-map :as routes] [cuerdas.core :as str])) @@ -36,7 +37,7 @@ }) (defn emailfrom [] - (if (not (clojure.string/blank? (environ/env :email-from-address))) (environ/env :email-from-address) (str "no-reply@orcpub.com"))) + (if (not (s/blank? (environ/env :email-from-address))) (environ/env :email-from-address) (str "no-reply@orcpub.com"))) (defn send-verification-email [base-url {:keys [email username first-and-last-name]} verification-key] (postal/send-message (email-cfg) From 2e0bb685463e5dc5512dfc3ea6865e15e4d44be2 Mon Sep 17 00:00:00 2001 From: Craig Huther Date: Tue, 29 Sep 2020 12:15:59 -0400 Subject: [PATCH 4/4] Added SIGNATURE & EMAIL_ERRORS_TO to README --- README.md | 4 ++++ docker-compose-build.yaml | 2 ++ docker-compose.yaml | 2 ++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index ff8475c29..918ea994c 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,13 @@ EMAIL_ACCESS_KEY: '' # User for the mail server EMAIL_SECRET_KEY: '' # Password for the user EMAIL_SERVER_PORT: 587 # Mail server port EMAIL_FROM_ADDRESS: '' # Email address to send from, will default to 'no-reply@orcpub.com' +EMAIL_ERRORS_TO: '' # Email address that errors will be sent to EMAIL_SSL: 'false' # Should SSL be used? Gmail requires this. EMAIL_TLS: 'false' # Should TLS be used? DATOMIC_URL: datomic:free://datomic:4334/orcpub?password=yourpassword # Url for the database ADMIN_PASSWORD: supersecretpassword #The datomic admin password (should be diffrent than the DATOMIC_PASSWORD) DATOMIC_PASSWORD: yourpassword #The datomic application password +SIGNATURE: '' # The Secret used to hash your password in the browser, 20+ characters recommended ``` The `ADMIN_PASSWORD` and `DATOMIC_PASSWORD` @@ -195,10 +197,12 @@ EMAIL_ACCESS_KEY: '' # User for the mail server EMAIL_SECRET_KEY: '' # Password for the user EMAIL_SERVER_PORT: 587 # Mail server port EMAIL_FROM_ADDRESS: '' # Email address to send from, will default to 'no-reply@orcpub.com' +EMAIL_ERRORS_TO: '' # Email address that errors will be sent to EMAIL_SSL: 'false' # Should SSL be used? Gmail requires this. DATOMIC_URL: datomic:free://datomic:4334/orcpub?password=yourpassword # Url for the database ADMIN_PASSWORD: supersecretpassword DATOMIC_PASSWORD: yourpassword +SIGNATURE: '' # The Secret used to hash your password in the browser, 20+ characters recommended ``` To change the datomic passwords you can do it through the environment variables `ADMIN_PASSWORD_OLD` and `DATOMIC_PASSWORD_OLD` start the container once, then set the `ADMIN_PASSWORD` and `DATOMIC_PASSWORD` to your new passwords. diff --git a/docker-compose-build.yaml b/docker-compose-build.yaml index 69cb33960..296e97768 100644 --- a/docker-compose-build.yaml +++ b/docker-compose-build.yaml @@ -19,6 +19,8 @@ services: EMAIL_TLS: 'FALSE' # Datomic connection string - Make sure the matches the DATOMIC_PASSWORD below DATOMIC_URL: datomic:free://datomic:4334/orcpub?password= + # The secret used to hash your password in the browser, 20+ characters recommended + SIGNATURE: '' depends_on: - datomic restart: always diff --git a/docker-compose.yaml b/docker-compose.yaml index e743171a4..5ebaa5048 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -17,6 +17,8 @@ services: EMAIL_TLS: 'FALSE' # Datomic connection string - Make sure the matches the DATOMIC_PASSWORD below DATOMIC_URL: datomic:free://datomic:4334/orcpub?password= + # The secret used to hash your password in the browser, 20+ characters recommended + SIGNATURE: '' depends_on: - datomic restart: always