mini_api.php 2.7 KB

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