Skip to content

Commit

Permalink
Extracted secret key to environment variable for improve security (#1)
Browse files Browse the repository at this point in the history
* fix(config): extracted secret key to environment variable for improved security

* fix: secret key loaded into the "run tests" step
  • Loading branch information
xsamueljr authored Dec 17, 2024
1 parent 0ad81f1 commit 756a995
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ jobs:
python -m pip install -r requirements.txt -r requirements-dev.txt
- name: Run tests
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: python -m pytest -vv
6 changes: 6 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

load_dotenv()

SECRET_KEY = os.getenv("SECRET_KEY")

if SECRET_KEY is None:
logger.error("`SECRET_KEY` environment variable must be set")
exit(1)

PORT = int(os.getenv("PORT", 3000))
HOST = os.getenv("HOST", "127.0.0.1")

Expand Down
3 changes: 2 additions & 1 deletion security/json_web_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import jwt
from jwt.exceptions import InvalidTokenError

SECRET_KEY = "534b743934c2b72c5f910b527c84594632c3355b7b7a6d87b97cf2b3d9726550"
from config import SECRET_KEY

ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES = 30

Expand Down

0 comments on commit 756a995

Please sign in to comment.