From 8e71e8e7f4bd42a23787fa266a8ff4ced24b149b Mon Sep 17 00:00:00 2001 From: Fabio Widmer Date: Wed, 12 Aug 2020 16:12:41 +0200 Subject: [PATCH 1/7] A few (self hosting) improvements --- app/config.py | 2 ++ app/models.py | 15 +++++++++++++-- example.env | 3 +++ templates/footer.html | 6 +++--- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/config.py b/app/config.py index 7ba40f00..7ddb1024 100644 --- a/app/config.py +++ b/app/config.py @@ -252,6 +252,8 @@ if LOCAL_FILE_UPLOAD: LANDING_PAGE_URL = os.environ.get("LANDING_PAGE_URL") or "https://simplelogin.io" +STATUS_PAGE_URL = os.environ.get("STATUS_PAGE_URL") or "https://status.simplelogin.io" + # Loading PGP keys when mail_handler runs. To be used locally when init_app is not called. LOAD_PGP_EMAIL_HANDLER = "LOAD_PGP_EMAIL_HANDLER" in os.environ diff --git a/app/models.py b/app/models.py index 5894cb33..05f37284 100644 --- a/app/models.py +++ b/app/models.py @@ -1078,7 +1078,18 @@ class Contact(db.Model, ModelMixin): """ # Prefer using contact name if possible + user = self.user name = self.name + email = self.website_email + + if ( + not user + or not SenderFormatEnum.has_value(user.sender_format) + or user.sender_format == SenderFormatEnum.AT.value + ): + email = email.replace("@", " at ") + elif user.sender_format == SenderFormatEnum.A.value: + email = email.replace("@", "(a)") # if no name, try to parse it from website_from if not name and self.website_from: @@ -1098,9 +1109,9 @@ class Contact(db.Model, ModelMixin): name = name.replace('"', "") if name: - name = name + " | " + self.website_email.replace("@", " at ") + name = name + " | " + email else: - name = self.website_email.replace("@", " at ") + name = email # cannot use formataddr here as this field is for email client, not for MTA return f'"{name}" <{self.reply_email}>' diff --git a/example.env b/example.env index 79d70470..c4d3238b 100644 --- a/example.env +++ b/example.env @@ -135,6 +135,9 @@ FACEBOOK_CLIENT_SECRET=to_fill # The landing page # LANDING_PAGE_URL=https://simplelogin.io +# The status page +# STATUS_PAGE_URL=https://status.simplelogin.io + # Used when querying info on Apple API # APPLE_API_SECRET=secret # MACAPP_APPLE_API_SECRET=secret diff --git a/templates/footer.html b/templates/footer.html index a3c260e2..703cec45 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -5,7 +5,7 @@
    -
  • +
  • Website
  • @@ -14,10 +14,10 @@
  • Developer Documentation
  • -
  • +
  • Status
  • -
  • Contact Us +
  • Contact Us
  • Date: Fri, 14 Aug 2020 16:23:29 +0200 Subject: [PATCH 2/7] More self hosting improvements --- README.md | 4 ++-- app/dashboard/templates/dashboard/api_key.html | 6 +++--- .../templates/dashboard/custom_domain.html | 2 +- app/email_utils.py | 3 ++- static/logo.png | Bin 0 -> 20074 bytes templates/emails/base.html | 4 ++-- templates/emails/com/newsletter/mailbox.html | 2 +- templates/emails/com/newsletter/mailbox.txt | 2 +- .../emails/com/newsletter/mobile-darkmode.html | 6 +++--- .../emails/com/newsletter/mobile-darkmode.txt | 6 +++--- templates/emails/com/newsletter/pgp.html | 4 ++-- templates/emails/com/newsletter/pgp.txt | 4 ++-- .../com/onboarding/browser-extension.html | 10 +++++----- .../emails/com/onboarding/browser-extension.txt | 10 +++++----- templates/emails/com/onboarding/mailbox.html | 6 +++--- templates/emails/com/onboarding/mailbox.txt | 4 ++-- templates/emails/com/onboarding/pgp.html | 4 ++-- templates/emails/com/onboarding/pgp.txt | 4 ++-- .../emails/com/onboarding/send-from-alias.html | 2 +- .../emails/com/onboarding/send-from-alias.txt | 2 +- templates/emails/com/safari-extension.html | 4 ++-- templates/emails/com/safari-extension.txt | 4 ++-- templates/emails/com/welcome.html | 4 ++-- templates/emails/com/welcome.txt | 4 ++-- .../send-from-alias-from-unknown-sender.html | 2 +- .../send-from-alias-from-unknown-sender.txt | 2 +- .../emails/transactional/subscription-end.html | 4 ++-- templates/emails/transactional/trial-end.html | 4 ++-- 28 files changed, 57 insertions(+), 56 deletions(-) create mode 100644 static/logo.png diff --git a/README.md b/README.md index 209e1d5b..c31b22e3 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,11 @@ [SimpleLogin](https://simplelogin.io) | Privacy-First Email Forwarding and Identity Provider Service ---

    - + - + diff --git a/app/dashboard/templates/dashboard/api_key.html b/app/dashboard/templates/dashboard/api_key.html index 2309ee7c..53b891d2 100644 --- a/app/dashboard/templates/dashboard/api_key.html +++ b/app/dashboard/templates/dashboard/api_key.html @@ -22,11 +22,11 @@

    + {% if (GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET) or (GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET) or (FACEBOOK_CLIENT_ID and FACEBOOK_CLIENT_SECRET) %}
    Social Login is now deprecated
    + {% endif %} {% endblock %} \ No newline at end of file diff --git a/app/auth/templates/auth/social.html b/app/auth/templates/auth/social.html index c5ca016e..363f058a 100644 --- a/app/auth/templates/auth/social.html +++ b/app/auth/templates/auth/social.html @@ -12,20 +12,26 @@
    Social login
    + {% if GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET %} - Sign in with Github + Sign in with GitHub + {% endif %} + {% if GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET %} Sign in with Google + {% endif %} + {% if FACEBOOK_CLIENT_ID and FACEBOOK_CLIENT_SECRET %} Sign in with Facebook + {% endif %}
Warning From aa18b7ecd1569f6efb6269e91450ba9266765044 Mon Sep 17 00:00:00 2001 From: Fabio Widmer Date: Tue, 18 Aug 2020 08:47:41 +0200 Subject: [PATCH 6/7] Add variables to Jinja --- .../oauth/authorize_nonlogin_user.html | 2 +- server.py | 22 +++++++++++++++++++ templates/emails/base.html | 2 +- templates/single.html | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/oauth/templates/oauth/authorize_nonlogin_user.html b/app/oauth/templates/oauth/authorize_nonlogin_user.html index 9cb3df75..8629e6e4 100644 --- a/app/oauth/templates/oauth/authorize_nonlogin_user.html +++ b/app/oauth/templates/oauth/authorize_nonlogin_user.html @@ -4,7 +4,7 @@
diff --git a/server.py b/server.py index 63c57555..0be46c1f 100644 --- a/server.py +++ b/server.py @@ -41,6 +41,17 @@ from app.config import ( FIRST_ALIAS_DOMAIN, SESSION_COOKIE_NAME, ADMIN_EMAIL, + PLAUSIBLE_HOST, + PLAUSIBLE_DOMAIN, + GITHUB_CLIENT_ID, + GITHUB_CLIENT_SECRET, + GOOGLE_CLIENT_ID, + GOOGLE_CLIENT_SECRET, + FACEBOOK_CLIENT_ID, + FACEBOOK_CLIENT_SECRET, + LANDING_PAGE_URL, + STATUS_PAGE_URL, + SUPPORT_EMAIL, ) from app.dashboard.base import dashboard_bp from app.developer.base import developer_bp @@ -456,6 +467,17 @@ def jinja2_filter(app): SENTRY_DSN=SENTRY_FRONT_END_DSN, VERSION=SHA1, FIRST_ALIAS_DOMAIN=FIRST_ALIAS_DOMAIN, + PLAUSIBLE_HOST=PLAUSIBLE_HOST, + PLAUSIBLE_DOMAIN=PLAUSIBLE_DOMAIN, + GITHUB_CLIENT_ID=GITHUB_CLIENT_ID, + GITHUB_CLIENT_SECRET=GITHUB_CLIENT_SECRET, + GOOGLE_CLIENT_ID=GOOGLE_CLIENT_ID, + GOOGLE_CLIENT_SECRET=GOOGLE_CLIENT_SECRET, + FACEBOOK_CLIENT_ID=FACEBOOK_CLIENT_ID, + FACEBOOK_CLIENT_SECRET=FACEBOOK_CLIENT_SECRET, + LANDING_PAGE_URL=LANDING_PAGE_URL, + STATUS_PAGE_URL=STATUS_PAGE_URL, + SUPPORT_EMAIL=SUPPORT_EMAIL, ) diff --git a/templates/emails/base.html b/templates/emails/base.html index 1409f33e..9ca8391d 100644 --- a/templates/emails/base.html +++ b/templates/emails/base.html @@ -448,7 +448,7 @@ diff --git a/templates/single.html b/templates/single.html index 9132c18e..eff6daa1 100644 --- a/templates/single.html +++ b/templates/single.html @@ -6,7 +6,7 @@
From 6a45010740fd556894d8a657a3a74fce1699e81f Mon Sep 17 00:00:00 2001 From: Fabio Widmer Date: Sat, 22 Aug 2020 18:38:44 +0200 Subject: [PATCH 7/7] Remove secret variables from Jinja --- app/auth/templates/auth/login.html | 2 +- app/auth/templates/auth/social.html | 6 +++--- server.py | 6 ------ .../transactional/send-from-alias-from-unknown-sender.html | 2 +- .../transactional/send-from-alias-from-unknown-sender.txt | 2 +- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/auth/templates/auth/login.html b/app/auth/templates/auth/login.html index 49b04c4b..79f2ba8c 100644 --- a/app/auth/templates/auth/login.html +++ b/app/auth/templates/auth/login.html @@ -49,7 +49,7 @@ Don't have an account yet? Sign up
- {% if (GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET) or (GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET) or (FACEBOOK_CLIENT_ID and FACEBOOK_CLIENT_SECRET) %} + {% if GITHUB_CLIENT_ID or GOOGLE_CLIENT_ID or FACEBOOK_CLIENT_ID %}
Social Login is now deprecated
diff --git a/app/auth/templates/auth/social.html b/app/auth/templates/auth/social.html index 363f058a..1218a1ac 100644 --- a/app/auth/templates/auth/social.html +++ b/app/auth/templates/auth/social.html @@ -12,21 +12,21 @@
Social login
- {% if GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET %} + {% if GITHUB_CLIENT_ID %} Sign in with GitHub {% endif %} - {% if GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET %} + {% if GOOGLE_CLIENT_ID %} Sign in with Google {% endif %} - {% if FACEBOOK_CLIENT_ID and FACEBOOK_CLIENT_SECRET %} + {% if FACEBOOK_CLIENT_ID %} Sign in with Facebook diff --git a/server.py b/server.py index 0be46c1f..6775f5f7 100644 --- a/server.py +++ b/server.py @@ -44,11 +44,8 @@ from app.config import ( PLAUSIBLE_HOST, PLAUSIBLE_DOMAIN, GITHUB_CLIENT_ID, - GITHUB_CLIENT_SECRET, GOOGLE_CLIENT_ID, - GOOGLE_CLIENT_SECRET, FACEBOOK_CLIENT_ID, - FACEBOOK_CLIENT_SECRET, LANDING_PAGE_URL, STATUS_PAGE_URL, SUPPORT_EMAIL, @@ -470,11 +467,8 @@ def jinja2_filter(app): PLAUSIBLE_HOST=PLAUSIBLE_HOST, PLAUSIBLE_DOMAIN=PLAUSIBLE_DOMAIN, GITHUB_CLIENT_ID=GITHUB_CLIENT_ID, - GITHUB_CLIENT_SECRET=GITHUB_CLIENT_SECRET, GOOGLE_CLIENT_ID=GOOGLE_CLIENT_ID, - GOOGLE_CLIENT_SECRET=GOOGLE_CLIENT_SECRET, FACEBOOK_CLIENT_ID=FACEBOOK_CLIENT_ID, - FACEBOOK_CLIENT_SECRET=FACEBOOK_CLIENT_SECRET, LANDING_PAGE_URL=LANDING_PAGE_URL, STATUS_PAGE_URL=STATUS_PAGE_URL, SUPPORT_EMAIL=SUPPORT_EMAIL, diff --git a/templates/emails/transactional/send-from-alias-from-unknown-sender.html b/templates/emails/transactional/send-from-alias-from-unknown-sender.html index 9f09ceae..e33a26b8 100644 --- a/templates/emails/transactional/send-from-alias-from-unknown-sender.html +++ b/templates/emails/transactional/send-from-alias-from-unknown-sender.html @@ -9,7 +9,7 @@ {{ render_text('This user has been also informed of this incident.') }} - {{ render_text('If you have any question, you can contact us by replying to this email or consult our website at ' ~ URL ~ '.') }} + {{ render_text('If you have any question, you can contact us by replying to this email or consult our website at ' ~ LANDING_PAGE_URL ~ '.') }} {{ render_text('Regards,
SimpleLogin Team.') }} {% endblock %} diff --git a/templates/emails/transactional/send-from-alias-from-unknown-sender.txt b/templates/emails/transactional/send-from-alias-from-unknown-sender.txt index 590f9a3a..93181064 100644 --- a/templates/emails/transactional/send-from-alias-from-unknown-sender.txt +++ b/templates/emails/transactional/send-from-alias-from-unknown-sender.txt @@ -7,7 +7,7 @@ We have recorded an attempt to send an email from your email ({{sender}}) to {{r {{reply_email}} is a special email address that only receives emails from its authorized user. This user has been also informed of this incident. -If you have any question, you can contact us by replying to this email or consult our website at {{URL}}. +If you have any question, you can contact us by replying to this email or consult our website at {{LANDING_PAGE_URL}}. Regards, SimpleLogin team.