From 3913cf571f375b1e51f3f66004a0b32454cf3b9c Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 15 Apr 2023 11:36:23 -0700 Subject: [PATCH 1/9] Make SMTP port and TLS configurable --- apiserver/plane/settings/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apiserver/plane/settings/common.py b/apiserver/plane/settings/common.py index c144eeb0b..b3a6883bd 100644 --- a/apiserver/plane/settings/common.py +++ b/apiserver/plane/settings/common.py @@ -174,11 +174,11 @@ EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" # Host for sending e-mail. EMAIL_HOST = os.environ.get("EMAIL_HOST") # Port for sending e-mail. -EMAIL_PORT = 587 +EMAIL_PORT = int(os.environ.get("EMAIL_PORT", 587)) # Optional SMTP authentication information for EMAIL_HOST. EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER") EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD") -EMAIL_USE_TLS = True +EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS", "1") == "1" SIMPLE_JWT = { @@ -210,4 +210,4 @@ SIMPLE_JWT = { CELERY_TIMEZONE = TIME_ZONE CELERY_TASK_SERIALIZER = 'json' -CELERY_ACCEPT_CONTENT = ['application/json'] \ No newline at end of file +CELERY_ACCEPT_CONTENT = ['application/json'] From 6af54ebbe75b9491e203e7cd8efb67be56766351 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 15 Apr 2023 12:32:00 -0700 Subject: [PATCH 2/9] Fix typo in `.env.example --- apiserver/.env.example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apiserver/.env.example b/apiserver/.env.example index 15056f072..2e1ee6fd1 100644 --- a/apiserver/.env.example +++ b/apiserver/.env.example @@ -3,11 +3,11 @@ DJANGO_SETTINGS_MODULE="plane.settings.production" DATABASE_URL=postgres://plane:xyzzyspoon@db:5432/plane # Cache REDIS_URL=redis://redis:6379/ -# SMPT +# SMTP EMAIL_HOST="" EMAIL_HOST_USER="" EMAIL_HOST_PASSWORD="" -# AWS +# AWS AWS_REGION="" AWS_ACCESS_KEY_ID="" AWS_SECRET_ACCESS_KEY="" @@ -21,4 +21,4 @@ DISABLE_COLLECTSTATIC=1 DOCKERIZED=1 # GPT Envs OPENAI_API_KEY=0 -GPT_ENGINE=0 \ No newline at end of file +GPT_ENGINE=0 From f757d8232b56b5d94ed853a6e6c00763905f8610 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 15 Apr 2023 12:32:54 -0700 Subject: [PATCH 3/9] Add setting to disable extra TLS config for Celery broker connection --- apiserver/plane/settings/production.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apiserver/plane/settings/production.py b/apiserver/plane/settings/production.py index 8f8453aff..a3f2ea79d 100644 --- a/apiserver/plane/settings/production.py +++ b/apiserver/plane/settings/production.py @@ -239,8 +239,12 @@ SLACK_BOT_TOKEN = os.environ.get("SLACK_BOT_TOKEN", False) LOGGER_BASE_URL = os.environ.get("LOGGER_BASE_URL", False) +broker_ssl = os.environ.get("REDIS_BROKER_SSL", "1") == "1" redis_url = os.environ.get("REDIS_URL") -broker_url = f"{redis_url}?ssl_cert_reqs={ssl.CERT_NONE.name}&ssl_ca_certs={certifi.where()}" +if broker_ssl: + broker_url = f"{redis_url}?ssl_cert_reqs={ssl.CERT_NONE.name}&ssl_ca_certs={certifi.where()}" +else: + broker_url = redis_url CELERY_RESULT_BACKEND = broker_url -CELERY_BROKER_URL = broker_url \ No newline at end of file +CELERY_BROKER_URL = broker_url From e2294f91058e14b2c67918a4f2470d634af77e56 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 15 Apr 2023 12:51:23 -0700 Subject: [PATCH 4/9] Add `EMAIL_FROM` setting to change sender email for messages --- apiserver/plane/bgtasks/email_verification_task.py | 3 ++- apiserver/plane/bgtasks/forgot_password_task.py | 3 ++- apiserver/plane/bgtasks/magic_link_code_task.py | 3 ++- apiserver/plane/bgtasks/project_invitation_task.py | 3 ++- apiserver/plane/bgtasks/workspace_invitation_task.py | 2 +- apiserver/plane/db/models/user.py | 2 +- apiserver/plane/settings/common.py | 1 + 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apiserver/plane/bgtasks/email_verification_task.py b/apiserver/plane/bgtasks/email_verification_task.py index ee4680e53..1da3a7510 100644 --- a/apiserver/plane/bgtasks/email_verification_task.py +++ b/apiserver/plane/bgtasks/email_verification_task.py @@ -2,6 +2,7 @@ from django.core.mail import EmailMultiAlternatives from django.template.loader import render_to_string from django.utils.html import strip_tags +from django.conf import settings # Third party imports from celery import shared_task @@ -20,7 +21,7 @@ def email_verification(first_name, email, token, current_site): realtivelink = "/request-email-verification/" + "?token=" + str(token) abs_url = "http://" + current_site + realtivelink - from_email_string = f"Team Plane " + from_email_string = settings.EMAIL_FROM subject = f"Verify your Email!" diff --git a/apiserver/plane/bgtasks/forgot_password_task.py b/apiserver/plane/bgtasks/forgot_password_task.py index 4598e5f2f..f13f1b89a 100644 --- a/apiserver/plane/bgtasks/forgot_password_task.py +++ b/apiserver/plane/bgtasks/forgot_password_task.py @@ -2,6 +2,7 @@ from django.core.mail import EmailMultiAlternatives from django.template.loader import render_to_string from django.utils.html import strip_tags +from django.conf import settings # Third party imports from celery import shared_task @@ -18,7 +19,7 @@ def forgot_password(first_name, email, uidb64, token, current_site): realtivelink = f"/email-verify/?uidb64={uidb64}&token={token}/" abs_url = "http://" + current_site + realtivelink - from_email_string = f"Team Plane " + from_email_string = settings.EMAIL_FROM subject = f"Verify your Email!" diff --git a/apiserver/plane/bgtasks/magic_link_code_task.py b/apiserver/plane/bgtasks/magic_link_code_task.py index 89554dcca..ea97b0fb8 100644 --- a/apiserver/plane/bgtasks/magic_link_code_task.py +++ b/apiserver/plane/bgtasks/magic_link_code_task.py @@ -2,6 +2,7 @@ from django.core.mail import EmailMultiAlternatives from django.template.loader import render_to_string from django.utils.html import strip_tags +from django.conf import settings # Third party imports from celery import shared_task @@ -14,7 +15,7 @@ def magic_link(email, key, token, current_site): realtivelink = f"/magic-sign-in/?password={token}&key={key}" abs_url = "http://" + current_site + realtivelink - from_email_string = f"Team Plane " + from_email_string = settings.EMAIL_FROM subject = f"Login for Plane" diff --git a/apiserver/plane/bgtasks/project_invitation_task.py b/apiserver/plane/bgtasks/project_invitation_task.py index 18e539970..1c3597120 100644 --- a/apiserver/plane/bgtasks/project_invitation_task.py +++ b/apiserver/plane/bgtasks/project_invitation_task.py @@ -2,6 +2,7 @@ from django.core.mail import EmailMultiAlternatives from django.template.loader import render_to_string from django.utils.html import strip_tags +from django.conf import settings # Third party imports from celery import shared_task @@ -22,7 +23,7 @@ def project_invitation(email, project_id, token, current_site): relativelink = f"/project-member-invitation/{project_member_invite.id}" abs_url = "http://" + current_site + relativelink - from_email_string = f"Team Plane " + from_email_string = settings.EMAIL_FROM subject = f"{project.created_by.first_name or project.created_by.email} invited you to join {project.name} on Plane" diff --git a/apiserver/plane/bgtasks/workspace_invitation_task.py b/apiserver/plane/bgtasks/workspace_invitation_task.py index c6e69689b..0ce32eee0 100644 --- a/apiserver/plane/bgtasks/workspace_invitation_task.py +++ b/apiserver/plane/bgtasks/workspace_invitation_task.py @@ -27,7 +27,7 @@ def workspace_invitation(email, workspace_id, token, current_site, invitor): ) abs_url = "http://" + current_site + realtivelink - from_email_string = f"Team Plane " + from_email_string = settings.EMAIL_FROM subject = f"{invitor or email} invited you to join {workspace.name} on Plane" diff --git a/apiserver/plane/db/models/user.py b/apiserver/plane/db/models/user.py index 334ec3e13..5a4f487c1 100644 --- a/apiserver/plane/db/models/user.py +++ b/apiserver/plane/db/models/user.py @@ -109,7 +109,7 @@ def send_welcome_email(sender, instance, created, **kwargs): if created and not instance.is_bot: first_name = instance.first_name.capitalize() to_email = instance.email - from_email_string = f"Team Plane " + from_email_string = settings.EMAIL_FROM subject = f"Welcome to Plane ✈️!" diff --git a/apiserver/plane/settings/common.py b/apiserver/plane/settings/common.py index b3a6883bd..f5bff248b 100644 --- a/apiserver/plane/settings/common.py +++ b/apiserver/plane/settings/common.py @@ -179,6 +179,7 @@ EMAIL_PORT = int(os.environ.get("EMAIL_PORT", 587)) EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER") EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD") EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS", "1") == "1" +EMAIL_FROM = os.environ.get("EMAIL_FROM", "Team Plane ") SIMPLE_JWT = { From 5e5d1a4699599ac9a10b4b4cff89984a93466f97 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Sat, 15 Apr 2023 12:56:43 -0700 Subject: [PATCH 5/9] Update `.env.example` with newly-added env vars --- apiserver/.env.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apiserver/.env.example b/apiserver/.env.example index 2e1ee6fd1..a3972379d 100644 --- a/apiserver/.env.example +++ b/apiserver/.env.example @@ -3,10 +3,14 @@ DJANGO_SETTINGS_MODULE="plane.settings.production" DATABASE_URL=postgres://plane:xyzzyspoon@db:5432/plane # Cache REDIS_URL=redis://redis:6379/ +REDIS_BROKER_SSL=0 # SMTP EMAIL_HOST="" EMAIL_HOST_USER="" EMAIL_HOST_PASSWORD="" +EMAIL_PORT="587" +EMAIL_USE_TLS="1" +EMAIL_FROM="Team Plane " # AWS AWS_REGION="" AWS_ACCESS_KEY_ID="" From 792162ae667c4993a3c85449122582be91086e37 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Mon, 17 Apr 2023 12:37:57 -0700 Subject: [PATCH 6/9] Remove redundant `$REDIS_BROKER_SSL` setting A fix was already pushed upstream that made this setting unnecessary --- apiserver/.env.example | 1 - apiserver/plane/settings/production.py | 1 - 2 files changed, 2 deletions(-) diff --git a/apiserver/.env.example b/apiserver/.env.example index a3972379d..e2625c1ed 100644 --- a/apiserver/.env.example +++ b/apiserver/.env.example @@ -3,7 +3,6 @@ DJANGO_SETTINGS_MODULE="plane.settings.production" DATABASE_URL=postgres://plane:xyzzyspoon@db:5432/plane # Cache REDIS_URL=redis://redis:6379/ -REDIS_BROKER_SSL=0 # SMTP EMAIL_HOST="" EMAIL_HOST_USER="" diff --git a/apiserver/plane/settings/production.py b/apiserver/plane/settings/production.py index 68758135e..d8f2a8bb7 100644 --- a/apiserver/plane/settings/production.py +++ b/apiserver/plane/settings/production.py @@ -239,7 +239,6 @@ SLACK_BOT_TOKEN = os.environ.get("SLACK_BOT_TOKEN", False) LOGGER_BASE_URL = os.environ.get("LOGGER_BASE_URL", False) -broker_ssl = os.environ.get("REDIS_BROKER_SSL", "1") == "1" redis_url = os.environ.get("REDIS_URL") broker_url = f"{redis_url}?ssl_cert_reqs={ssl.CERT_NONE.name}&ssl_ca_certs={certifi.where()}" From ca2366aa9b124bb9f0d6a5152f1b5c7d983d9c36 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Mon, 17 Apr 2023 14:07:00 -0700 Subject: [PATCH 7/9] Use env var to set `AWS_S3_ENDPOINT_URL` setting --- apiserver/plane/settings/production.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apiserver/plane/settings/production.py b/apiserver/plane/settings/production.py index d8f2a8bb7..3a590f3b2 100644 --- a/apiserver/plane/settings/production.py +++ b/apiserver/plane/settings/production.py @@ -105,7 +105,7 @@ if ( AWS_S3_ADDRESSING_STYLE = "auto" # The full URL to the S3 endpoint. Leave blank to use the default region URL. - AWS_S3_ENDPOINT_URL = "" + AWS_S3_ENDPOINT_URL = os.environ.get("AWS_S3_ENDPOINT_URL", "") # A prefix to be applied to every stored file. This will be joined to every filename using the "/" separator. AWS_S3_KEY_PREFIX = "" From b8c06b31215c46aa341823bae21db1bbb40d2464 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Mon, 17 Apr 2023 14:08:47 -0700 Subject: [PATCH 8/9] Add `$AWS_S3_ENDPOINT_URL` to `.env.example` --- apiserver/.env.example | 1 + 1 file changed, 1 insertion(+) diff --git a/apiserver/.env.example b/apiserver/.env.example index e2625c1ed..8a7c76ffa 100644 --- a/apiserver/.env.example +++ b/apiserver/.env.example @@ -15,6 +15,7 @@ AWS_REGION="" AWS_ACCESS_KEY_ID="" AWS_SECRET_ACCESS_KEY="" AWS_S3_BUCKET_NAME="" +AWS_S3_ENDPOINT_URL="" # FE WEB_URL="localhost/" # OAUTH From ea87823478b1e2a110357198e356dfc77822f33c Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Mon, 17 Apr 2023 16:30:36 -0700 Subject: [PATCH 9/9] Add `$NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS` to add domains for Next Image plugin --- apps/app/.env.example | 3 ++- apps/app/next.config.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/app/.env.example b/apps/app/.env.example index 1e2576dfc..cdf30fc72 100644 --- a/apps/app/.env.example +++ b/apps/app/.env.example @@ -1,5 +1,6 @@ # Replace with your instance Public IP # NEXT_PUBLIC_API_BASE_URL = "http://localhost" +NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS= NEXT_PUBLIC_GOOGLE_CLIENTID="" NEXT_PUBLIC_GITHUB_APP_NAME="" NEXT_PUBLIC_GITHUB_ID="" @@ -7,4 +8,4 @@ NEXT_PUBLIC_SENTRY_DSN="" NEXT_PUBLIC_ENABLE_OAUTH=0 NEXT_PUBLIC_ENABLE_SENTRY=0 NEXT_PUBLIC_ENABLE_SESSION_RECORDER=0 -NEXT_PUBLIC_TRACK_EVENTS=0 \ No newline at end of file +NEXT_PUBLIC_TRACK_EVENTS=0 diff --git a/apps/app/next.config.js b/apps/app/next.config.js index d194a6cc7..b3c67eedd 100644 --- a/apps/app/next.config.js +++ b/apps/app/next.config.js @@ -1,5 +1,6 @@ const { withSentryConfig } = require("@sentry/nextjs"); const path = require("path"); +const extraImageDomains = (process.env.NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS ?? "").split(",").filter((domain) => domain.length > 0); const nextConfig = { reactStrictMode: false, @@ -11,6 +12,7 @@ const nextConfig = { "planefs.s3.amazonaws.com", "images.unsplash.com", "avatars.githubusercontent.com", + ...extraImageDomains, ], }, output: "standalone",