Skip to content

Commit

Permalink
Merge pull request #311 from RISPaDD/email-settings-using-secrets
Browse files Browse the repository at this point in the history
Use env vars and aws secrets for all email settings
  • Loading branch information
jamienoss authored Mar 21, 2024
2 parents 039c57a + 7004a94 commit 9134286
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions apprunner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ run:
- name: DJANGO_SETTINGS_MODULE
value: "biospecdb.settings.aws"
secrets:
- name: EMAIL_USE_TLS
value-from: "arn:aws:secretsmanager:eu-west-2:339712857727:secret:EMAIL_USE_TLS-KbwnER"
- name: EMAIL_USE_SSL
value-from: "arn:aws:secretsmanager:eu-west-2:339712857727:secret:EMAIL_USE_SSL-4jjkpd"
- name: EMAIL_PORT
value-from: "arn:aws:secretsmanager:eu-west-2:339712857727:secret:EMAIL_PORT-G0axai"
- name: EMAIL_TIMEOUT
value-from: "arn:aws:secretsmanager:eu-west-2:339712857727:secret:EMAIL_TIMEOUT-rwHtBm"
- name: DJANGO_LOG_LEVEL
Expand Down
8 changes: 5 additions & 3 deletions biospecdb/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,15 @@
# Email settings
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = os.getenv("EMAIL_HOST")
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_USE_TLS = os.getenv("EMAIL_USE_TLS", "True").strip() == "True" # This is mutually exclusive with EMAIL_USE_SSL.
EMAIL_USE_SSL = os.getenv("EMAIL_USE_SSL", "False").strip() == "True" # This is mutually exclusive with EMAIL_USE_TSL.
assert not (EMAIL_USE_TLS and EMAIL_USE_SSL)
EMAIL_PORT = int(os.getenv("EMAIL_PORT", 587)) # TLS on 587 and SSL on 465.
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
EMAIL_FROM = f"admin@{HOST_DOMAIN}"
EMAIL_SUBJECT_PREFIX = os.getenv("EMAIL_SUBJECT_PREFIX")
EMAIL_TIMEOUT = os.getenv("EMAIL_TIMEOUT")
EMAIL_TIMEOUT = int(os.getenv("EMAIL_TIMEOUT", 60))

# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/
Expand Down

0 comments on commit 9134286

Please sign in to comment.