app/config.py module defines configuration classes for different deployment environments, managing API endpoints, secrets, and application behavior.
Base Configuration
Config
Base configuration class with production defaults. Class:app.config.Config
Environment Variables
Secret key for authenticating with Notify API
Flask secret key for session signing and CSRF protection
Base URL for Notify API (e.g.,
https://api.notifications.service.gov.uk)Environment name for logging (e.g.,
production, staging, development)Log level for request logging (DEBUG, INFO, WARNING, ERROR, CRITICAL)
Public URL for Document Download API (e.g.,
https://download.notifications.service.gov.uk)Internal URL for Document Download API (may differ from public URL for internal networking)
GOV.UK header bar color (hex code)
Protocol for secure cookie settings (
http or https)Class Attributes
Development Configuration
Development
Configuration for local development environment. Class:app.config.Development
Inherits: Config
Development-Specific Settings
Flask server name for URL generation (e.g.,
localhost:6002)Local Notify API URL
Local Document Download API public URL
Local Document Download API internal URL (same as public in development)
Overrides
DEBUG = True: Enables Flask debug mode with auto-reload and detailed error pages- Default localhost URLs for all API endpoints
- Insecure default secrets (never use in production)
Test Configuration
Test
Configuration for automated testing environment. Class:app.config.Test
Inherits: Development
Test-Specific Settings
Enables Flask testing mode
Disables CSRF protection for easier testing
Test domain for URL generation
- Mock API hosts for predictable testing
- HTTPS URLs to test secure cookie behavior
- Separate internal/external API URLs to test cookie domain logic
Configuration Selection
Configurations are selected via theNOTIFY_ENVIRONMENT environment variable:
NOTIFY_ENVIRONMENT=development→ UsesDevelopmentclassNOTIFY_ENVIRONMENT=test→ UsesTestclass- Any other value (including
production,staging) → Uses baseConfigclass
Production and staging environments use the base
Config class and must provide all required environment variables.Environment Variable Examples
Development
Production
Testing
Configuration Access
Access configuration in application code:Security Considerations
Secret Key Requirements
ADMIN_CLIENT_SECRET:- Used for API authentication with Notify backend
- Must match the secret configured for
notify-adminservice ID
- Used by Flask for session signing and CSRF tokens
- Should be cryptographically random (e.g.,
secrets.token_hex(32)) - Must remain consistent across application restarts to preserve sessions
HTTPS Configuration
HTTP_PROTOCOL:- Set to
"https"in production for secure cookies - Affects cookie
Secureflag in email verification flow
Related Documentation
- Application Initialization - How configuration is loaded
- ServiceApiClient - API client configuration usage
- View Functions - Configuration in route handlers