-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use django-environ to load Env variables #11
base: main
Are you sure you want to change the base?
Changes from 3 commits
5d9580d
998e088
7bc9a59
02c3ba6
14d18c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
SECRET_KEY=changeme | ||
DEBUG=true | ||
DATABASE_URL=postgres:///connect | ||
DJANGO_ALLOWED_HOSTS= | ||
TWILIO_ACCOUNT_SID= | ||
TWILIO_AUTH_TOKEN= | ||
TWILIO_MESSAGING_SERVICE= | ||
FCM_CREDENTIALS= |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,14 @@ | |
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/4.1/ref/settings/ | ||
""" | ||
import os | ||
import environ | ||
|
||
from pathlib import Path | ||
|
||
# Build paths inside the project like this: BASE_DIR / 'subdir'. | ||
BASE_DIR = Path(__file__).resolve().parent.parent | ||
|
||
env = environ.Env() | ||
env.read_env(str(BASE_DIR / ".env")) | ||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ | ||
|
@@ -196,10 +197,38 @@ | |
"DELETE_INACTIVE_DEVICES": False, | ||
} | ||
|
||
from .localsettings import * | ||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = env( | ||
"SECRET_KEY", | ||
default="django-insecure-yofpqrszrdtv0ftihjd09cuim2al9^n9j^b85%-y0v*^_lj18d", | ||
) | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = env("DEBUG", default=False) | ||
|
||
# Database | ||
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases | ||
|
||
DATABASES = { | ||
"default": env.db( | ||
"DATABASE_URL", | ||
default="postgres:///connect", | ||
), | ||
} | ||
|
||
ALLOWED_HOSTS = ["127.0.0.1", "localhost"] + env.list( | ||
"DJANGO_ALLOWED_HOSTS", default=[] | ||
) | ||
|
||
TWILIO_ACCOUNT_SID = env("TWILIO_ACCOUNT_SID") | ||
TWILIO_AUTH_TOKEN = env("TWILIO_AUTH_TOKEN") | ||
TWILIO_MESSAGING_SERVICE = env("TWILIO_MESSAGING_SERVICE") | ||
|
||
FCM_CREDENTIALS = env("FCM_CREDENTIALS", default=None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably allow only individual fields within FCM_CREDENTIALs to be configured via env? (instead of the full JSON) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. 14d18c0 |
||
|
||
# Firebase | ||
if FCM_CREDENTIALS: | ||
from firebase_admin import credentials, initialize_app | ||
|
||
creds = credentials.Certificate(FCM_CREDENTIALS) | ||
default_app = initialize_app(credential=creds) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ phonenumberslite | |
psycopg2 | ||
twilio | ||
zxcvbn | ||
fcm-django | ||
fcm-django | ||
django-environ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,6 @@ | |
# | ||
asgiref==3.6.0 | ||
# via django | ||
build==0.10.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you know why there are so many requirements changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, pip-tools is not in the |
||
# via pip-tools | ||
cachecontrol==0.13.1 | ||
# via firebase-admin | ||
cachetools==5.3.1 | ||
|
@@ -18,8 +16,6 @@ cffi==1.15.1 | |
# via cryptography | ||
charset-normalizer==3.1.0 | ||
# via requests | ||
click==8.1.3 | ||
# via pip-tools | ||
cryptography==41.0.2 | ||
# via | ||
# jwcrypto | ||
|
@@ -34,6 +30,8 @@ django==4.1.7 | |
# django-phonenumber-field | ||
# djangorestframework | ||
# fcm-django | ||
django-environ==0.11.2 | ||
# via -r requirements.in | ||
django-oauth-toolkit==2.3.0 | ||
# via -r requirements.in | ||
django-otp==1.1.6 | ||
|
@@ -100,12 +98,8 @@ msgpack==1.0.7 | |
# via cachecontrol | ||
oauthlib==3.2.2 | ||
# via django-oauth-toolkit | ||
packaging==23.1 | ||
# via build | ||
phonenumberslite==8.13.11 | ||
# via -r requirements.in | ||
pip-tools==6.13.0 | ||
# via -r requirements.in | ||
proto-plus==1.22.3 | ||
# via google-cloud-firestore | ||
protobuf==4.24.4 | ||
|
@@ -131,8 +125,6 @@ pyjwt[crypto]==2.6.0 | |
# twilio | ||
pyparsing==3.1.1 | ||
# via httplib2 | ||
pyproject-hooks==1.0.0 | ||
# via build | ||
pytz==2022.7.1 | ||
# via | ||
# djangorestframework | ||
|
@@ -154,17 +146,11 @@ uritemplate==4.1.1 | |
# via google-api-python-client | ||
urllib3==1.26.15 | ||
# via requests | ||
wheel==0.40.0 | ||
# via pip-tools | ||
wrapt==1.15.0 | ||
# via deprecated | ||
zxcvbn==4.4.28 | ||
# via -r requirements.in | ||
|
||
# The following packages are considered to be unsafe in a requirements file: | ||
pip==23.1.2 | ||
# via pip-tools | ||
setuptools==67.8.0 | ||
# via | ||
# gunicorn | ||
# pip-tools | ||
setuptools==69.0.3 | ||
# via gunicorn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are missing two settings from prod here
CSRF_TRUSTED_ORIGINS
and private-key part ofOAUTH2_PROVIDER
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. 14d18c0