Skip to content

fix: move hardcoded DB credentials and Flask secret key to environment variables#31

Merged
brick-24 merged 4 commits into
brick-24:mainfrom
Tejas5405:fix/move-db-creds-to-env-vars
Jun 20, 2026
Merged

fix: move hardcoded DB credentials and Flask secret key to environment variables#31
brick-24 merged 4 commits into
brick-24:mainfrom
Tejas5405:fix/move-db-creds-to-env-vars

Conversation

@Tejas5405

Copy link
Copy Markdown
Contributor

Problem

Database credentials and Flask secret key were hardcoded in source files:

src/config.py

host = "localhost"
user = "USERNAME"
password = "PASSWORD"

src/app.py

app.secret_key = "your_secret_key"

Hardcoded credentials are a security risk — anyone who clones the repo sees them, and they get committed to git history. This is especially problematic when deploying to cloud environments (Railway, Render, AWS, etc.).

Fix

  • src/config.py: Load MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD from environment using python-dotenv
  • src/app.py: Load FLASK_SECRET_KEY from environment
  • .env.example: Added template so contributors know which variables to set

Usage after this fix

cp .env.example .env
# Fill in your values in .env
pip install python-dotenv
python src/app.py

References

@brick-24

Copy link
Copy Markdown
Owner

Tested locally, reviewed implementation, LGTM.

@brick-24 brick-24 self-assigned this Jun 20, 2026
@brick-24 brick-24 self-requested a review June 20, 2026 21:36

@brick-24 brick-24 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, added .env to .gitignore

@brick-24 brick-24 merged commit 0f9ab93 into brick-24:main Jun 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: Move db creds from config.py to env variables

2 participants