|
1 | 1 | { |
| 2 | + // =========================================================================================== |
| 3 | + // DEVELOPMENT ENVIRONMENT CONFIGURATION |
| 4 | + // =========================================================================================== |
| 5 | + // This file overrides settings in appsettings.json for local development |
| 6 | + // Settings here are ONLY used when running in Development environment |
| 7 | + // |
| 8 | + // How environment detection works: |
| 9 | + // - Determined by ASPNETCORE_ENVIRONMENT variable |
| 10 | + // - Visual Studio automatically sets this to "Development" |
| 11 | + // - In production, set to "Production" |
| 12 | + // |
| 13 | + // Configuration loading order (later files override earlier): |
| 14 | + // 1. appsettings.json (base configuration) |
| 15 | + // 2. appsettings.{Environment}.json (environment-specific) |
| 16 | + // 3. User Secrets (development only) |
| 17 | + // 4. Environment Variables |
| 18 | + // 5. Command-line arguments |
| 19 | + // =========================================================================================== |
| 20 | + |
| 21 | + // ===== Development Logging Configuration ===== |
| 22 | + // More verbose logging for debugging and troubleshooting |
| 23 | + // Production uses less verbose settings for performance |
2 | 24 | "Logging": { |
3 | 25 | "LogLevel": { |
4 | | - "Default": "Information", |
5 | | - "Microsoft.AspNetCore": "Warning" |
| 26 | + // Default: Debug level shows detailed information for debugging |
| 27 | + // Includes: method entry/exit, variable values, execution flow |
| 28 | + // Performance impact: Higher than Information (acceptable in dev) |
| 29 | + "Default": "Debug", |
| 30 | + |
| 31 | + // ASP.NET Core: Information level for request/response details |
| 32 | + // Shows: HTTP requests, route matching, middleware execution |
| 33 | + // Useful for debugging routing and middleware issues |
| 34 | + "Microsoft.AspNetCore": "Information", |
| 35 | + |
| 36 | + // Entity Framework Core: Information level for database queries |
| 37 | + // Shows: Generated SQL queries, parameter values, query execution time |
| 38 | + // Essential for debugging database operations |
| 39 | + "Microsoft.EntityFrameworkCore": "Information", |
| 40 | + |
| 41 | + // Application logs: Debug level for maximum visibility |
| 42 | + // Shows all application-specific logging |
| 43 | + "SecureCleanApiWaf": "Debug" |
6 | 44 | } |
| 45 | + }, |
| 46 | + |
| 47 | + // =========================================================================================== |
| 48 | + // DEVELOPMENT JWT SETTINGS (DO NOT USE IN PRODUCTION) |
| 49 | + // =========================================================================================== |
| 50 | + // Development-friendly JWT configuration |
| 51 | + // - Longer expiration times for easier testing |
| 52 | + // - Clear labeling (Dev suffix) to prevent production confusion |
| 53 | + // - Simpler secret key (still meets minimum length requirement) |
| 54 | + // |
| 55 | + // 🚨 WARNING: These settings are intentionally insecure for development convenience |
| 56 | + // NEVER deploy to production with these settings! |
| 57 | + "JwtSettings": { |
| 58 | + // Development secret key (32+ characters required) |
| 59 | + // Different from production to prevent accidental token interchange |
| 60 | + // Clearly labeled as "Development" to avoid confusion |
| 61 | + "SecretKey": "Development_Secret_Key_32Characters_Minimum!", |
| 62 | + |
| 63 | + // Issuer: Labeled as "Dev" to differentiate from production tokens |
| 64 | + // Tokens generated in dev won't be accepted by production API |
| 65 | + "Issuer": "SecureCleanApiWaf.Dev", |
| 66 | + |
| 67 | + // Audience: Labeled as "Dev" environment |
| 68 | + "Audience": "SecureCleanApiWaf.Api.Dev", |
| 69 | + |
| 70 | + // Longer expiration for development convenience |
| 71 | + // 120 minutes (2 hours) reduces need to repeatedly generate tokens |
| 72 | + // Allows longer debugging sessions without token expiration |
| 73 | + // Production: Use 15-30 minutes for security |
| 74 | + "ExpirationMinutes": 120, |
| 75 | + |
| 76 | + // Longer refresh token expiration for development |
| 77 | + // 30 days: Very permissive for local testing |
| 78 | + // Production: Use 7-14 days maximum |
| 79 | + "RefreshTokenExpirationDays": 30 |
| 80 | + }, |
| 81 | + |
| 82 | + // =========================================================================================== |
| 83 | + // DEVELOPMENT EXTERNAL API CONFIGURATION |
| 84 | + // =========================================================================================== |
| 85 | + // Configuration for testing external API integrations locally |
| 86 | + "ThirdPartyApi": { |
| 87 | + // JSONPlaceholder: Free fake REST API for testing |
| 88 | + // Provides realistic data without requiring real API credentials |
| 89 | + // Features: users, posts, comments, albums, photos, todos |
| 90 | + // No authentication required (perfect for development) |
| 91 | + // |
| 92 | + // Documentation: https://jsonplaceholder.typicode.com/ |
| 93 | + "BaseUrl": "https://jsonplaceholder.typicode.com/", |
| 94 | + |
| 95 | + // Development API key placeholder |
| 96 | + // For APIs that require authentication: |
| 97 | + // 1. Sign up for a developer account |
| 98 | + // 2. Get API key from provider |
| 99 | + // 3. Store in User Secrets (not in source control) |
| 100 | + // 4. Replace this placeholder |
| 101 | + // |
| 102 | + // To use User Secrets: |
| 103 | + // 1. Right-click project → Manage User Secrets |
| 104 | + // 2. Add: "ThirdPartyApi": { "ApiKey": "your-actual-key" } |
| 105 | + // 3. User Secrets override this setting locally |
| 106 | + "ApiKey": "dev-api-key-placeholder-replace-with-real-key", |
| 107 | + |
| 108 | + // Longer timeout for development (60 seconds) |
| 109 | + // Allows: |
| 110 | + // - Debugging external API calls with breakpoints |
| 111 | + // - Testing with slow development APIs |
| 112 | + // - Network throttling for testing timeout handling |
| 113 | + // Production: Use 30 seconds or less |
| 114 | + "Timeout": 60 |
| 115 | + }, |
| 116 | + |
| 117 | + // =========================================================================================== |
| 118 | + // DEVELOPMENT CORS CONFIGURATION (MORE PERMISSIVE) |
| 119 | + // =========================================================================================== |
| 120 | + // Allow more origins for local development convenience |
| 121 | + // Supports various local development scenarios |
| 122 | + "Cors": { |
| 123 | + "AllowedOrigins": [ |
| 124 | + // HTTPS development server (default Blazor port) |
| 125 | + "https://localhost:7000", |
| 126 | + |
| 127 | + // Alternative HTTPS port (Kestrel default) |
| 128 | + "https://localhost:5001", |
| 129 | + |
| 130 | + // HTTP development server (for testing non-HTTPS scenarios) |
| 131 | + // 🚨 NOTE: HTTPS should be used even in development |
| 132 | + // This is here for legacy/compatibility testing only |
| 133 | + "http://localhost:5000" |
| 134 | + ] |
| 135 | + }, |
| 136 | + |
| 137 | + // =========================================================================================== |
| 138 | + // DEVELOPMENT RATE LIMITING (MORE PERMISSIVE) |
| 139 | + // =========================================================================================== |
| 140 | + // Relaxed rate limits for development and testing |
| 141 | + // Allows rapid API testing without hitting limits |
| 142 | + // |
| 143 | + // Development vs Production: |
| 144 | + // - Dev: 200 req/min, 5000 req/hour (very permissive) |
| 145 | + // - Prod: 60 req/min, 1000 req/hour (more restrictive) |
| 146 | + "IpRateLimiting": { |
| 147 | + // Enable rate limiting even in development |
| 148 | + // Ensures code doesn't break when deployed to production |
| 149 | + // Helps catch issues with rate limit handling early |
| 150 | + "EnableEndpointRateLimiting": true, |
| 151 | + |
| 152 | + // Don't stack blocked requests in development |
| 153 | + // Makes testing rate limiting easier |
| 154 | + "StackBlockedRequests": false, |
| 155 | + |
| 156 | + // Development rate limit rules (more permissive) |
| 157 | + "GeneralRules": [ |
| 158 | + { |
| 159 | + // Per-minute limit: 200 requests |
| 160 | + // Allows rapid testing: ~3 requests per second |
| 161 | + // Enough for automated tests and rapid manual testing |
| 162 | + "Endpoint": "*", |
| 163 | + "Period": "1m", |
| 164 | + "Limit": 200 |
| 165 | + }, |
| 166 | + { |
| 167 | + // Hourly limit: 5000 requests |
| 168 | + // Allows intensive development sessions |
| 169 | + // High enough that legitimate development never hits it |
| 170 | + // Low enough to catch runaway loops in code |
| 171 | + "Endpoint": "*", |
| 172 | + "Period": "1h", |
| 173 | + "Limit": 5000 |
| 174 | + } |
| 175 | + ] |
| 176 | + }, |
| 177 | + |
| 178 | + // =========================================================================================== |
| 179 | + // DEVELOPMENT DATABASE CONFIGURATION |
| 180 | + // =========================================================================================== |
| 181 | + // More verbose logging and error details for debugging database issues |
| 182 | + "DatabaseSettings": { |
| 183 | + // LocalDB connection (built into Visual Studio) |
| 184 | + // No installation required, perfect for development |
| 185 | + // Database file stored in user's AppData folder |
| 186 | + "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=SecureCleanApiWaf;Trusted_Connection=True;TrustServerCertificate=True;MultipleActiveResultSets=True", |
| 187 | + |
| 188 | + // Enable sensitive data logging in development |
| 189 | + // Shows parameter values in SQL queries for debugging |
| 190 | + // Example: "SELECT * FROM Users WHERE Email = @p0" with @p0 = "user@example.com" |
| 191 | + "EnableSensitiveDataLogging": true, |
| 192 | + |
| 193 | + // Enable detailed errors in development |
| 194 | + // Shows full exception details including SQL query text |
| 195 | + // Helps debug query issues and schema problems |
| 196 | + "EnableDetailedErrors": true, |
| 197 | + |
| 198 | + // Command timeout: 60 seconds (generous for development) |
| 199 | + // Allows debugging queries with breakpoints |
| 200 | + "CommandTimeout": 60, |
| 201 | + |
| 202 | + // Retry configuration (same as production) |
| 203 | + // Tests retry logic during development |
| 204 | + "MaxRetryCount": 3, |
| 205 | + "MaxRetryDelay": 30, |
| 206 | + |
| 207 | + // Query splitting: false (default behavior) |
| 208 | + // Can set to true to test splitting behavior |
| 209 | + "EnableQuerySplitting": false |
7 | 210 | } |
| 211 | + |
| 212 | + // =========================================================================================== |
| 213 | + // DEVELOPMENT TIPS & BEST PRACTICES |
| 214 | + // =========================================================================================== |
| 215 | + // |
| 216 | + // 1. USER SECRETS FOR SENSITIVE DATA: |
| 217 | + // Don't hardcode API keys or passwords even in development |
| 218 | + // Use User Secrets feature: |
| 219 | + // - Right-click project → Manage User Secrets |
| 220 | + // - Store sensitive values there (never committed to source control) |
| 221 | + // |
| 222 | + // 2. HTTPS EVEN IN DEVELOPMENT: |
| 223 | + // Use HTTPS certificates even locally (Visual Studio generates them) |
| 224 | + // Prevents certificate issues when deploying to production |
| 225 | + // Matches production behavior more closely |
| 226 | + // |
| 227 | + // 3. TEST WITH PRODUCTION-LIKE SETTINGS: |
| 228 | + // Occasionally test with stricter settings (short JWT expiration, etc.) |
| 229 | + // Ensures code handles token refresh, rate limiting, etc. |
| 230 | + // |
| 231 | + // 4. ENVIRONMENT VARIABLE TESTING: |
| 232 | + // Test overriding settings via environment variables |
| 233 | + // Ensures deployment configuration works correctly |
| 234 | + // |
| 235 | + // 5. LOG LEVEL MANAGEMENT: |
| 236 | + // Use Debug for active development |
| 237 | + // Switch to Information when sharing logs (less noise) |
| 238 | + // Use Warning/Error for performance testing |
| 239 | + // |
| 240 | + // 6. DATABASE CONFIGURATION: |
| 241 | + // Use local database for development (LocalDB, SQLite) |
| 242 | + // Don't connect to production databases from development |
| 243 | + // Use realistic test data |
| 244 | + // |
| 245 | + // =========================================================================================== |
8 | 246 | } |
0 commit comments