mini_api.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. return [
  3. // Independent opaque sessions; test identities are isolated from WeChat.
  4. // This API never uses the admin JWT verifier or trusts user IDs sent by the client.
  5. 'token_verifier' => \app\miniapi\auth\SessionVerifier::class,
  6. 'wechat_appid' => env('MINI_WECHAT_APPID', ''),
  7. 'wechat_secret' => env('MINI_WECHAT_SECRET', ''),
  8. 'environment' => env('APP_ENV', 'production'),
  9. 'test_phone_login' => filter_var(env('MINI_TEST_PHONE_LOGIN', false), FILTER_VALIDATE_BOOLEAN),
  10. // Only these peers may set X-Forwarded-For. Behind a reverse proxy every caller otherwise
  11. // shares one address, which merges login throttling.
  12. // Loopback is trusted by default because it is unreachable from the network; list every
  13. // proxy hop explicitly when deploying behind Nginx or a load balancer.
  14. 'trusted_proxies' => array_values(array_filter(array_map('trim', explode(',', (string) env(
  15. 'MINI_TRUSTED_PROXIES',
  16. '127.0.0.1,::1'
  17. ))))),
  18. // SMS login is a second credential for an account that already exists: the phone must be
  19. // bound by an administrator first. Codes are stored only as hashes and are single use.
  20. 'sms_login' => filter_var(env('MINI_SMS_LOGIN', false), FILTER_VALIDATE_BOOLEAN),
  21. 'sms_user' => (string) env('MINI_SMS_USER', ''),
  22. 'sms_password' => (string) env('MINI_SMS_PASSWORD', ''),
  23. 'sms_endpoint' => (string) env('MINI_SMS_ENDPOINT', 'https://api.smsbao.com/sms'),
  24. 'sms_signature' => (string) env('MINI_SMS_SIGNATURE', ''),
  25. // Optional extra HMAC key for code hashing; falls back to the SMS password, which is already secret.
  26. 'sms_code_pepper' => (string) env('MINI_SMS_CODE_PEPPER', ''),
  27. 'sms_code_ttl' => 120,
  28. 'sms_resend_interval' => 60,
  29. 'sms_max_attempts' => 5,
  30. 'sms_daily_per_phone' => 10,
  31. 'sms_per_ip_per_hour' => 30,
  32. 'session_ttl' => 604800,
  33. 'login_ip_per_minute' => 60,
  34. 'login_global_per_minute' => 600,
  35. 'max_photo_body_bytes' => 3000000,
  36. 'support_phone' => env('MINI_SUPPORT_PHONE', ''),
  37. 'purchase_agreement_url' => env('MINI_PURCHASE_AGREEMENT_URL', ''),
  38. 'privacy_url' => env('MINI_PRIVACY_URL', ''),
  39. 'max_body_bytes' => 65536,
  40. 'max_page_size' => 100,
  41. // Exact browser origins only. Local Swagger UI is served by the API on port 8787.
  42. // Override with a comma-separated list for HTTPS deployments; an empty value disables browser origins.
  43. 'allowed_origins' => array_values(array_filter(array_map('trim', explode(',', (string) env(
  44. 'MINI_ALLOWED_ORIGINS',
  45. 'http://127.0.0.1:8787,http://localhost:8787'
  46. ))))),
  47. ];