diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2a32f4b7..8d621e5c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -178,6 +178,12 @@ jobs: sentry: dsn: ${{ secrets.SENTRY_DSN }} jsLoaderUrl: ${{ secrets.SENTRY_JS_LOADER_URL }} + mailer: + primary: + host: ${{ secrets.DJANGO_MAILER_PRIMARY_HOST }} + port: ${{ secrets.DJANGO_MAILER_PRIMARY_HOST_PORT }} + user: ${{ secrets.DJANGO_MAILER_PRIMARY_HOST_USER }} + password: ${{ secrets.DJANGO_MAILER_PRIMARY_HOST_PASSWORD }} value-files: >- [ "charts/values.yaml" diff --git a/charts/templates/web-secret.yaml b/charts/templates/web-secret.yaml index d15b2139..bc4d6ed0 100644 --- a/charts/templates/web-secret.yaml +++ b/charts/templates/web-secret.yaml @@ -9,8 +9,14 @@ "DJANGO_AWS_S3_SECRET_ACCESS_KEY" (.Values.secrets.s3.accessKey | b64enc) "DJANGO_AWS_S3_REGION_NAME" (.Values.secrets.s3.regionName | b64enc) "DJANGO_AWS_STORAGE_BUCKET_NAME" (.Values.secrets.s3.bucketName | b64enc) + "DJANGO_SENTRY_DSN" (.Values.secrets.sentry.dsn | b64enc) "DJANGO_SENTRY_JS_LOADER_URL" (.Values.secrets.sentry.jsLoaderUrl | b64enc) + + "DJANGO_MAILER_PRIMARY_HOST" (.Values.secrets.mailer.primary.host | b64enc) + "DJANGO_MAILER_PRIMARY_HOST_PORT" (.Values.secrets.mailer.primary.port | b64enc) + "DJANGO_MAILER_PRIMARY_HOST_USER" (.Values.secrets.mailer.primary.user | b64enc) + "DJANGO_MAILER_PRIMARY_HOST_PASSWORD" (.Values.secrets.mailer.primary.password | b64enc) ) }} {{- include "fiesta.secret" (merge (dict "Args" $data) . ) -}} diff --git a/charts/values.yaml b/charts/values.yaml index f78f9d21..14868138 100644 --- a/charts/values.yaml +++ b/charts/values.yaml @@ -39,3 +39,9 @@ secrets: sentry: dsn: dsn jsLoaderUrl: url + mailer: + primary: + host: host + port: 587 + user: user + password: password diff --git a/fiesta/fiesta/settings/__init__.py b/fiesta/fiesta/settings/__init__.py index 6a562956..d5ed118f 100644 --- a/fiesta/fiesta/settings/__init__.py +++ b/fiesta/fiesta/settings/__init__.py @@ -8,6 +8,7 @@ from .db import DatabaseConfigMixin from .files import FilesConfigMixin, S3ConfigMixin from .logging import LoggingConfigMixin, SentryConfigMixin +from .notifications import SmtpMailerConfigMixin from .project import ProjectConfigMixin from .security import SecurityConfigMixin from .templates import TemplatesConfigMixin @@ -55,7 +56,12 @@ class LocalProduction(Base): USE_WEBPACK_INTEGRITY = False -class Production(S3ConfigMixin, SentryConfigMixin, Base): +class Production( + SmtpMailerConfigMixin, + S3ConfigMixin, + SentryConfigMixin, + Base, +): DEBUG = False ROOT_DOMAIN = Value(environ_required=True) diff --git a/fiesta/fiesta/settings/notifications.py b/fiesta/fiesta/settings/notifications.py new file mode 100644 index 00000000..e165c8f3 --- /dev/null +++ b/fiesta/fiesta/settings/notifications.py @@ -0,0 +1,38 @@ +from __future__ import annotations + +from configurations.values import SecretValue, Value + +from ._utils import BaseConfigurationProtocol + + +class SmtpMailerConfigMixin(BaseConfigurationProtocol): + MAILER_PRIMARY_BACKEND = Value(default="django.core.mail.backends.smtp.EmailBackend") + MAILER_PRIMARY_TIMEOUT = Value(default=5) + MAILER_PRIMARY_HOST = SecretValue() + MAILER_PRIMARY_HOST_PORT = SecretValue() + MAILER_PRIMARY_HOST_PASSWORD = SecretValue() + MAILER_PRIMARY_HOST_USER = SecretValue() + + @property + def EMAIL_BACKEND(self): + return self.MAILER_PRIMARY_BACKEND + + @property + def EMAIL_TIMEOUT(self): + return self.MAILER_PRIMARY_TIMEOUT + + @property + def EMAIL_HOST(self): + return self.MAILER_PRIMARY_HOST + + @property + def EMAIL_PORT(self): + return self.MAILER_PRIMARY_HOST_PORT + + @property + def EMAIL_HOST_USER(self): + return self.MAILER_PRIMARY_HOST_USER + + @property + def EMAIL_HOST_PASSWORD(self): + return self.MAILER_PRIMARY_HOST_PASSWORD diff --git a/fiesta/fiesta/settings/project.py b/fiesta/fiesta/settings/project.py index 653a843d..40af3261 100644 --- a/fiesta/fiesta/settings/project.py +++ b/fiesta/fiesta/settings/project.py @@ -38,8 +38,12 @@ class ProjectConfigMixin: def ALLOWED_HOSTS(self): return [f".{self.ROOT_DOMAIN}"] + # overwritten by production mixins EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" + def DEFAULT_FROM_EMAIL(self): + return f"Fiesta+ " + INSTALLED_APPS = [ # dj admin autocompletion widgets, must be before admin "dal",