Skip to content

Commit

Permalink
Fix the encrypt key variable
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Feb 7, 2024
1 parent 45a336f commit 5d6cb56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ APEX_DOMAIN=redirectioneaza.ro
SECRET_KEY="replace-this-example-key"
SENTRY_DSN=""
# key used for encrypting, data; has to be exactly 32 characters long
ECNRYPT_KEY="this-key-should-be-exactly-32-ch"
ENCRYPT_KEY="this-key-should-be-exactly-32-ch"

CORS_ALLOWED_ORIGINS=http://localhost:3000
CORS_ALLOW_ALL_ORIGINS=True
Expand Down
14 changes: 9 additions & 5 deletions backend/redirectioneaza/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,14 @@
}
}
else:
# create a sqlite database in the .db_sqlite directory
sqlite_path = os.path.join(BASE_DIR, ".db_sqlite", "db.sqlite3")

file = open(sqlite_path, "w+")
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.abspath(os.path.join(BASE_DIR, ".db_sqlite", "db.sqlite3")),
"NAME": os.path.abspath(sqlite_path),
}
}

Expand Down Expand Up @@ -472,7 +476,7 @@


# encryption
ECNRYPT_KEY = env.str("ECNRYPT_KEY")
if len(ECNRYPT_KEY) != 32:
raise Exception("ECNRYPT_KEY must be exactly 32 characters long")
FERNET_OBJECT = Fernet(urlsafe_b64encode(ECNRYPT_KEY.encode("utf-8")))
ENCRYPT_KEY = env.str("ENCRYPT_KEY", "%INVALID%")
if len(ENCRYPT_KEY) != 32 or ENCRYPT_KEY == "%INVALID%":
raise Exception("ENCRYPT_KEY must be exactly 32 characters long")
FERNET_OBJECT = Fernet(urlsafe_b64encode(ENCRYPT_KEY.encode("utf-8")))

0 comments on commit 5d6cb56

Please sign in to comment.