Skip to content

ENHANCEMENT: Move all hardcoded configuration to environment variables and Flask config system #17

Description

@Senthil455

Description

All sensitive configuration values are currently hardcoded in app.py as global variables. This is a security risk and makes deployment across different environments (dev, staging, production) error-prone.

Current Hardcoded Values

  • app.py:13 - app.secret_key = "your_secret_key"
  • app.py:15 - TEACHER_SUPERKEY = "1"
  • app.py:28-32 - Database credentials fallback (postgres / 4321)
  • app.py:37-39 - Hardcoded email domains (@student.annauniv.edu, @faculty.annauniv.edu)

Recommended Enhancement

  1. Create a proper configuration module using Flask's config system:

    class Config:
        SECRET_KEY = os.environ.get('SECRET_KEY', os.urandom(24).hex())
        TEACHER_SUPERKEY = os.environ.get('TEACHER_SUPERKEY', '')
        DATABASE_URL = os.environ.get('DATABASE_URL', '')
        STUDENT_EMAIL_DOMAIN = os.environ.get('STUDENT_EMAIL_DOMAIN', '@student.annauniv.edu')
        FACULTY_EMAIL_DOMAIN = os.environ.get('FACULTY_EMAIL_DOMAIN', '@faculty.annauniv.edu')
    
    app.config.from_object(Config)
  2. Add a .env.example file documenting all required environment variables:

    SECRET_KEY=<generate a random key>
    TEACHER_SUPERKEY=<generate a random key>
    DATABASE_URL=postgresql://user:password@host:port/dbname
    STUDENT_EMAIL_DOMAIN=@student.annauniv.edu
    FACULTY_EMAIL_DOMAIN=@faculty.annauniv.edu
    
  3. Recommend using python-dotenv for local development (load .env file automatically)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsecuritySecurity vulnerability or concern

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions