-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsettings.php
More file actions
101 lines (94 loc) · 4.35 KB
/
settings.php
File metadata and controls
101 lines (94 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
declare(strict_types=1);
use BigGive\Identity\Application\Settings\Settings;
use BigGive\Identity\Application\Settings\SettingsInterface;
use DI\ContainerBuilder;
use Monolog\Logger;
return function (ContainerBuilder $containerBuilder) {
// Global Settings Object
$containerBuilder->addDefinitions([
SettingsInterface::class => function () {
$isProduction = getenv('APP_ENV') === 'production';
$isLoadTest = !$isProduction && isset($_SERVER['HTTP_X_IS_LOAD_TEST']);
$doctrineConnectionOptions = [];
if (getenv('APP_ENV') !== 'local') {
$doctrineConnectionOptions[\Pdo\Mysql::ATTR_SSL_CA]
= dirname(__DIR__) . '/deploy/rds-ca-eu-west-1-bundle.pem';
}
/**
* @psalm-suppress RiskyTruthyFalsyComparison - hard to avoid when working with env variables.
*/
return new Settings([
'apiClient' => [
'global' => [
'timeout' => getenv('CLIENT_TIMEOUT'), // in seconds
],
'mailer' => [
'baseUri' => getenv('MAILER_BASE_URI'),
'sendSecret' => getenv('MAILER_SEND_SECRET'),
],
],
'appEnv' => getenv('APP_ENV'),
'bypassPsp' => $isLoadTest,
'displayErrorDetails' => ! $isProduction,
'doctrine' => [
// if true, metadata caching is forcefully disabled
'dev_mode' => in_array(getenv('APP_ENV'), ['local', 'test'], true),
'cache_dir' => __DIR__ . '/../var/doctrine',
'metadata_dirs' => [__DIR__ . '/../src/Domain'],
'connection' => [
'driver' => 'pdo_mysql',
'host' => getenv('MYSQL_HOST'),
'port' => 3306,
'dbname' => getenv('MYSQL_SCHEMA'),
'user' => getenv('MYSQL_USER'),
'password' => getenv('MYSQL_PASSWORD'),
'charset' => 'utf8mb4',
'default_table_options' => [
'collate' => 'utf8mb4_unicode_ci',
],
'options' => $doctrineConnectionOptions,
],
],
'logError' => false,
'logErrorDetails' => false,
'logger' => [
'name' => 'identity',
'path' => 'php://stdout',
'level' => getenv('APP_ENV') === 'local' ? Logger::DEBUG : Logger::INFO,
],
'los_rate_limit' => [
// Dynamic so we can increase it for load tests or as needed based on observed
// Production behaviour.
'ip_max_requests' => (int) (getenv('MAX_CREATES_PER_IP_PER_5M') ?: '1'),
'ip_reset_time' => 300, // 5 minutes
// All non-local envs, including 'test', assume ALB-style forwarded headers will be used.
'prefer_forwarded' => getenv('APP_ENV') !== 'local',
'trust_forwarded' => getenv('APP_ENV') !== 'local',
'forwarded_headers_allowed' => [
'X-Forwarded-For',
],
'hash_ips' => true, // Required for Redis storage of IPv6 addresses.
],
'friendly_captcha' => [
'api_key' => getenv('FRIENDLY_CAPTCHA_SECRET_KEY'),
'site_key' => getenv('FRIENDLY_CAPTCHA_SITE_KEY'),
'bypass' => $isLoadTest,
],
'redis' => [
'host' => getenv('REDIS_HOST'),
],
'stripe' => [
'apiKey' => getenv('STRIPE_SECRET_KEY'),
],
'accountManagement' => [
'baseUri' => getenv('ACCOUNT_MANAGEMENT_BASE_URI'),
],
'messenger' => [
// Outbound uses SQS in deployed AWS environments and Redis locally.
'outbound_dsn' => getenv('MESSENGER_OUTBOUND_TRANSPORT_DSN'),
],
]);
}
]);
};