Skip to content

Commit 5d6cb56

Browse files
committed
Fix the encrypt key variable
1 parent 45a336f commit 5d6cb56

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ APEX_DOMAIN=redirectioneaza.ro
1515
SECRET_KEY="replace-this-example-key"
1616
SENTRY_DSN=""
1717
# key used for encrypting, data; has to be exactly 32 characters long
18-
ECNRYPT_KEY="this-key-should-be-exactly-32-ch"
18+
ENCRYPT_KEY="this-key-should-be-exactly-32-ch"
1919

2020
CORS_ALLOWED_ORIGINS=http://localhost:3000
2121
CORS_ALLOW_ALL_ORIGINS=True

backend/redirectioneaza/settings.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,14 @@
245245
}
246246
}
247247
else:
248+
# create a sqlite database in the .db_sqlite directory
249+
sqlite_path = os.path.join(BASE_DIR, ".db_sqlite", "db.sqlite3")
250+
251+
file = open(sqlite_path, "w+")
248252
DATABASES = {
249253
"default": {
250254
"ENGINE": "django.db.backends.sqlite3",
251-
"NAME": os.path.abspath(os.path.join(BASE_DIR, ".db_sqlite", "db.sqlite3")),
255+
"NAME": os.path.abspath(sqlite_path),
252256
}
253257
}
254258

@@ -472,7 +476,7 @@
472476

473477

474478
# encryption
475-
ECNRYPT_KEY = env.str("ECNRYPT_KEY")
476-
if len(ECNRYPT_KEY) != 32:
477-
raise Exception("ECNRYPT_KEY must be exactly 32 characters long")
478-
FERNET_OBJECT = Fernet(urlsafe_b64encode(ECNRYPT_KEY.encode("utf-8")))
479+
ENCRYPT_KEY = env.str("ENCRYPT_KEY", "%INVALID%")
480+
if len(ENCRYPT_KEY) != 32 or ENCRYPT_KEY == "%INVALID%":
481+
raise Exception("ENCRYPT_KEY must be exactly 32 characters long")
482+
FERNET_OBJECT = Fernet(urlsafe_b64encode(ENCRYPT_KEY.encode("utf-8")))

0 commit comments

Comments
 (0)