This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
/
index.js
963 lines (951 loc) · 27.5 KB
/
index.js
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict'
var fs = require('fs')
var path = require('path')
var url = require('url')
var convict = require('convict')
var DEFAULT_SUPPORTED_LANGUAGES = require('./supportedLanguages')
const ONE_DAY = 1000 * 60 * 60 * 24
const ONE_YEAR = ONE_DAY * 365
const FIVE_MINUTES = 1000 * 60 * 5
var conf = convict({
env: {
doc: 'The current node.js environment',
default: 'prod',
format: [ 'dev', 'test', 'stage', 'prod' ],
env: 'NODE_ENV'
},
geodb: {
dbPath: {
doc: 'Path to the maxmind database file',
default: path.resolve(__dirname, '../node_modules/fxa-geodb/db/cities-db.mmdb'),
env: 'GEODB_DBPATH',
format: String
},
enabled: {
doc: 'kill-switch for geodb',
default: true,
env: 'GEODB_ENABLED',
format: Boolean
}
},
log: {
app: {
default: 'fxa-auth-server',
env: 'LOG_APP_NAME'
},
level: {
default: 'info',
env: 'LOG_LEVEL'
},
fmt: {
format: ['heka', 'pretty'],
default: 'heka',
env: 'LOG_FORMAT'
}
},
memcached: {
address: {
doc: 'Address:port of the memcached server (or `none` to disable memcached)',
default: '127.0.0.1:11211',
env: 'MEMCACHE_METRICS_CONTEXT_ADDRESS'
},
idle: {
doc: 'Idle timeout for memcached connections (milliseconds)',
format: Number,
default: 30000,
env: 'MEMCACHE_METRICS_CONTEXT_IDLE'
},
lifetime: {
doc: 'Lifetime for memcached values (seconds)',
format: 'nat',
default: 7200,
env: 'MEMCACHE_METRICS_CONTEXT_LIFETIME'
}
},
publicUrl: {
format: 'url',
default: 'http://127.0.0.1:9000',
env: 'PUBLIC_URL'
},
domain: {
format: 'url',
doc: 'Derived automatically from publicUrl',
default: undefined
},
secretKeyFile: {
format: String,
default: path.resolve(__dirname, '../config/secret-key.json'),
env: 'SECRET_KEY_FILE'
},
publicKeyFile: {
format: String,
default: path.resolve(__dirname, '../config/public-key.json'),
env: 'PUBLIC_KEY_FILE'
},
oldPublicKeyFile: {
format: String,
doc: 'Previous publicKeyFile, used for key rotation',
default: undefined,
env: 'OLD_PUBLIC_KEY_FILE'
},
vapidKeysFile: {
doc: 'Keys to use for VAPID in push notifications',
format: String,
default: path.resolve(__dirname, '../config/vapid-keys.json'),
env: 'VAPID_KEYS_FILE'
},
db: {
backend: {
default: 'httpdb',
env: 'DB_BACKEND'
},
connectionRetry: {
default: '10 seconds',
env: 'DB_CONNECTION_RETRY',
doc: 'Time in milliseconds to retry a database connection attempt',
format: 'duration'
},
connectionTimeout: {
default: '5 minutes',
env: 'DB_CONNECTION_TIMEOUT',
doc: 'Timeout in milliseconds after which the mailer will stop trying to connect to the database',
format: 'duration'
},
poolee: {
timeout: {
default: '5 seconds',
format: 'duration',
env: 'DB_POOLEE_TIMEOUT',
doc: 'Time in milliseconds to wait for db query completion'
},
maxPending: {
default: 1000,
format: 'int',
env: 'DB_POOLEE_MAX_PENDING',
doc: 'Number of pending requests to auth-db-mysql to allow'
}
}
},
httpdb: {
url: {
doc: 'database api url',
default: 'http://127.0.0.1:8000',
env: 'HTTPDB_URL'
}
},
listen: {
host: {
doc: 'The ip address the server should bind',
default: '127.0.0.1',
format: 'ipaddress',
env: 'IP_ADDRESS'
},
port: {
doc: 'The port the server should bind',
default: 9000,
format: 'port',
env: 'PORT'
}
},
customsUrl: {
doc: 'fraud / abuse server url; set to the string \'none\' to disable',
default: 'http://127.0.0.1:7000',
env: 'CUSTOMS_SERVER_URL'
},
contentServer: {
url: {
doc: 'The url of the corresponding fxa-content-server instance',
default: 'http://127.0.0.1:3030',
env: 'CONTENT_SERVER_URL'
}
},
emailService: {
host: {
doc: 'host for fxa-email-service',
format: 'ipaddress',
default: '127.0.0.1',
env: 'EMAIL_SERVICE_HOST'
},
port: {
doc: 'port for fxa-email-service',
format: 'port',
default: 8001,
env: 'EMAIL_SERVICE_PORT'
},
forcedEmailAddresses: {
doc: 'force usage of fxa-email-service when sending emails to addresses that match this pattern',
format: RegExp,
default: /emailservice\.[A-Za-z0-9._%+-]+@restmail\.net$/,
env: 'EMAIL_SERVICE_FORCE_EMAIL_REGEX'
},
},
smtp: {
api: {
host: {
doc: 'host for test/mail_helper.js',
default: '127.0.0.1',
env: 'MAILER_HOST'
},
port: {
doc: 'port for test/mail_helper.js',
default: 9001,
env: 'MAILER_PORT'
}
},
host: {
doc: 'SMTP host for sending email',
default: 'localhost',
env: 'SMTP_HOST'
},
port: {
doc: 'SMTP port',
default: 25,
env: 'SMTP_PORT'
},
secure: {
doc: 'Connect to SMTP host securely',
default: false,
env: 'SMTP_SECURE'
},
user: {
doc: 'SMTP username',
format: String,
default: undefined,
env: 'SMTP_USER'
},
password: {
doc: 'SMTP password',
format: String,
default: undefined,
env: 'SMTP_PASS'
},
sender: {
doc: 'email address of the sender',
default: 'Firefox Accounts <no-reply@lcip.org>',
env: 'SMTP_SENDER'
},
prependVerificationSubdomain: {
enabled: {
doc: 'Flag to prepend a verification subdomain to verification emails',
default: false,
env: 'PREPEND_VERIFICATION_SUBDOMAIN_ENABLED'
},
subdomain: {
doc: 'Prepend this subdomain',
format: String,
default: 'confirm',
env: 'PREPEND_VERIFICATION_SUBDOMAIN_SUBDOMAIN'
},
},
verificationUrl: {
doc: 'Deprecated. uses contentServer.url',
format: String,
default: undefined,
env: 'VERIFY_URL',
arg: 'verify-url'
},
verifyLoginUrl: {
doc: 'Deprecated. uses contentServer.url',
format: String,
default: undefined,
env: 'VERIFY_LOGIN_URL',
arg: 'verify-login-url'
},
passwordResetUrl: {
doc: 'Deprecated. uses contentServer.url',
format: String,
default: undefined,
env: 'RESET_URL',
arg: 'reset-url'
},
initiatePasswordResetUrl: {
doc: 'Deprecated. uses contentServer.url',
format: String,
default: undefined
},
syncUrl: {
doc: 'url to Sync product page',
format: String,
default: 'https://accounts.firefox.com/connect_another_device/'
},
androidUrl: {
doc: 'url to Android product page',
format: String,
default: 'https://app.adjust.com/2uo1qc?campaign=fxa-conf-email&adgroup=android&creative=button&utm_source=email'
},
iosUrl: {
doc: 'url to IOS product page',
format: String,
default: 'https://app.adjust.com/2uo1qc?campaign=fxa-conf-email&adgroup=ios&creative=button&fallback=https%3A%2F%2Fitunes.apple.com%2Fapp%2Fapple-store%2Fid989804926%3Fpt%3D373246%26ct%3Dadjust_tracker%26mt%3D8&utm_source=email'
},
supportUrl: {
doc: 'url to Mozilla Support product page',
format: String,
default: 'https://support.mozilla.org/kb/im-having-problems-with-my-firefox-account'
},
redirectDomain: {
doc: 'Domain that mail urls are allowed to redirect to',
format: String,
default: 'firefox.com',
env: 'REDIRECT_DOMAIN'
},
privacyUrl: {
doc: 'url to Mozilla privacy page',
format: String,
default: 'https://www.mozilla.org/privacy'
},
passwordManagerInfoUrl: {
doc: 'url to Firefox password manager information',
format: String,
default: 'https://support.mozilla.org/kb/password-manager-remember-delete-change-and-import#w_viewing-and-deleting-passwords'
},
sesConfigurationSet: {
doc: ('AWS SES Configuration Set for SES Event Publishing. If defined, ' +
'X-SES-MESSAGE-TAGS headers will be added to emails. Only ' +
'intended for Production/Stage use.'),
format: String,
default: '',
env: 'SES_CONFIGURATION_SET'
},
bounces: {
enabled: {
doc: 'Flag to enable checking for bounces before sending email',
default: true,
env: 'BOUNCES_ENABLED'
},
complaint: {
doc: 'Tiers of max allowed complaints per amount of milliseconds',
default: {
// 0 are allowed in the past day.
// 1 is allowed in the past year.
0: ONE_DAY,
1: ONE_YEAR
},
env: 'BOUNCES_COMPLAINT'
},
hard: {
doc: 'Tiers of max allowed hard bounces per amount of milliseconds',
default: {
// 0 are allowed in the past day.
// 1 is allowed in the past year.
0: ONE_DAY,
1: ONE_YEAR
},
env: 'BOUNCES_HARD'
},
soft: {
doc: 'Tiers of max allowed soft bounces per amount of milliseconds',
default: {
0: FIVE_MINUTES
},
env: 'BOUNCES_SOFT'
}
}
},
maxEventLoopDelay: {
doc: 'Max event-loop delay before which incoming requests are rejected',
default: 0,
env: 'MAX_EVENT_LOOP_DELAY'
},
scrypt: {
maxPending: {
doc: 'Max number of scrypt hash operations that can be pending',
default: 0,
env: 'SCRYPT_MAX_PENDING'
}
},
i18n: {
defaultLanguage: {
format: String,
default: 'en',
env: 'DEFAULT_LANG'
},
supportedLanguages: {
format: Array,
default: DEFAULT_SUPPORTED_LANGUAGES,
env: 'SUPPORTED_LANGS'
}
},
redis: {
host: {
default: '127.0.0.1',
env: 'REDIS_HOST',
format: String,
doc: 'IP address or host name for Redis server',
},
port: {
default: 6379,
env: 'REDIS_PORT',
format: 'port',
doc: 'Port for Redis server'
},
sessionTokens: {
enabled: {
default: true,
doc: 'Enable Redis for session tokens',
format: Boolean,
env: 'USE_REDIS'
},
prefix: {
default: 'fxa-auth-session',
env: 'SESSIONS_REDIS_KEY_PREFIX',
format: String,
doc: 'Key prefix for session tokens in Redis'
},
maxConnections: {
default: 200,
env: 'REDIS_POOL_MAX_CONNECTIONS',
format: 'int',
doc: 'Maximum connection count for the session token Redis pool'
},
minConnections: {
default: 2,
env: 'REDIS_POOL_MIN_CONNECTIONS',
format: 'int',
doc: 'Minimum connection count for the session token Redis pool'
}
},
email: {
enabled: {
default: true,
doc: 'Enable Redis for email config',
format: Boolean,
env: 'EMAIL_CONFIG_USE_REDIS'
},
prefix: {
default: 'email:',
env: 'EMAIL_CONFIG_REDIS_KEY_PREFIX',
format: String,
doc: 'Key prefix for the email config Redis pool'
},
maxConnections: {
default: 10,
env: 'EMAIL_CONFIG_REDIS_POOL_MAX_CONNECTIONS',
format: 'int',
doc: 'Maximum connection count for the email config Redis pool'
},
minConnections: {
default: 1,
env: 'EMAIL_CONFIG_REDIS_POOL_MIN_CONNECTIONS',
format: 'int',
doc: 'Minimum connection count for the email config Redis pool'
}
},
maxPending: {
default: 1000,
env: 'REDIS_POOL_MAX_PENDING',
format: 'int',
doc: 'Pending request limit for Redis'
},
retryCount: {
default: 5,
env: 'REDIS_POOL_RETRY_COUNT',
format: 'int',
doc: 'Retry limit for Redis connection attempts'
},
initialBackoff: {
default: '100 milliseconds',
env: 'REDIS_POOL_TIMEOUT',
format: 'duration',
doc: 'Initial backoff for Redis connection retries, increases exponentially with each attempt'
}
},
tokenLifetimes: {
accountResetToken: {
format: 'duration',
env: 'ACCOUNT_RESET_TOKEN_TTL',
default: '15 minutes'
},
passwordForgotToken: {
format: 'duration',
env: 'PASSWORD_FORGOT_TOKEN_TTL',
default: '60 minutes'
},
passwordChangeToken: {
format: 'duration',
env: 'PASSWORD_CHANGE_TOKEN_TTL',
default: '15 minutes'
},
sessionTokenWithoutDevice: {
doc: 'Maximum age for session tokens without a device record, specify zero to disable',
format: 'duration',
env: 'SESSION_TOKEN_WITHOUT_DEVICE_TTL',
default: '4 weeks'
}
},
tokenPruning: {
enabled: {
doc: 'Turn on Redis token pruning',
format: Boolean,
default: true,
env: 'TOKEN_PRUNING_ENABLED'
},
maxAge: {
doc: 'Age at which to prune expired tokens from Redis',
format: 'duration',
default: '1 month',
env: 'TOKEN_PRUNING_MAX_AGE'
}
},
verifierVersion: {
doc: 'verifer version for new and changed passwords',
format: 'int',
env: 'VERIFIER_VERSION',
default: 1
},
snsTopicArn: {
doc: 'Amazon SNS topic on which to send account event notifications. Set to "disabled" to turn off the notifier',
format: String,
env: 'SNS_TOPIC_ARN',
default: ''
},
snsTopicEndpoint: {
doc: 'Amazon SNS topic endpoint',
format: String,
env: 'SNS_TOPIC_ENDPOINT',
default: undefined
},
emailNotifications: {
region: {
doc: 'The region where the queues live, most likely the same region we are sending email e.g. us-east-1, us-west-2',
format: String,
env: 'BOUNCE_REGION',
default: ''
},
bounceQueueUrl: {
doc: 'The bounce queue URL to use (should include https://sqs.<region>.amazonaws.com/<account-id>/<queue-name>)',
format: String,
env: 'BOUNCE_QUEUE_URL',
default: ''
},
complaintQueueUrl: {
doc: 'The complaint queue URL to use (should include https://sqs.<region>.amazonaws.com/<account-id>/<queue-name>)',
format: String,
env: 'COMPLAINT_QUEUE_URL',
default: ''
},
deliveryQueueUrl: {
doc: 'The email delivery queue URL to use (should include https://sqs.<region>.amazonaws.com/<account-id>/<queue-name>)',
format: String,
env: 'DELIVERY_QUEUE_URL',
default: ''
},
notificationQueueUrl: {
doc: 'Queue URL for notifications from fxa-email-service (eventually this will be the only email-related queue)',
format: String,
env: 'NOTIFICATION_QUEUE_URL',
default: ''
}
},
profileServerMessaging: {
region: {
doc: 'The region where the queues live',
format: String,
env: 'PROFILE_MESSAGING_REGION',
default: ''
},
profileUpdatesQueueUrl: {
doc: 'The queue URL to use (should include https://sqs.<region>.amazonaws.com/<account-id>/<queue-name>)',
format: String,
env: 'PROFILE_UPDATES_QUEUE_URL',
default: ''
}
},
useHttps: {
doc: 'set to true to serve directly over https',
env: 'USE_TLS',
default: false
},
keyPath: {
doc: 'path to SSL key in PEM format if serving over https',
env: 'TLS_KEY_PATH',
default: path.resolve(__dirname, '../key.pem')
},
certPath: {
doc: 'path to SSL certificate in PEM format if serving over https',
env: 'TLS_CERT_PATH',
default: path.resolve(__dirname, '../cert.pem')
},
lockoutEnabled: {
doc: 'Is account lockout enabled',
format: Boolean,
env: 'LOCKOUT_ENABLED',
default: false
},
// A safety switch to disable device metadata updates,
// in case problems with the client logic cause server overload.
deviceUpdatesEnabled: {
doc: 'Are updates to device metadata enabled?',
format: Boolean,
env: 'DEVICE_UPDATES_ENABLED',
default: true
},
// A safety switch to disable device-driven notifications,
// in case problems with the client logic cause server overload.
deviceNotificationsEnabled: {
doc: 'Are device-driven notifications enabled?',
format: Boolean,
env: 'DEVICE_NOTIFICATIONS_ENABLED',
default: true
},
oauth: {
url: {
format: 'url',
doc: 'URL at which to verify OAuth tokens',
default: 'http://localhost:9010',
env: 'OAUTH_URL'
},
keepAlive: {
format: Boolean,
doc: 'Use HTTP keep-alive connections when talking to oauth server',
env: 'OAUTH_KEEPALIVE',
default: false
},
clientIds: {
doc: 'Mappings from client id to service name: { "id1": "name-1", "id2": "name-2" }',
format: Object,
default: {},
env: 'OAUTH_CLIENT_IDS'
},
clientInfoCacheTTL: {
doc: 'TTL for OAuth client details (in milliseconds)',
format: 'duration',
default: '3 days',
env: 'OAUTH_CLIENT_INFO_CACHE_TTL'
}
},
metrics: {
flow_id_key: {
default: 'YOU MUST CHANGE ME',
doc: 'FlowId validation key, as used by content-server',
format: String,
env: 'FLOW_ID_KEY'
},
flow_id_expiry: {
doc: 'Time after which flowIds are considered stale.',
format: 'duration',
default: '2 hours',
env: 'FLOW_ID_EXPIRY'
}
},
corsOrigin: {
doc: 'Value for the Access-Control-Allow-Origin response header',
format: Array,
env: 'CORS_ORIGIN',
default: ['*']
},
clientAddressDepth: {
doc: 'location of the client ip address in the remote address chain',
format: Number,
env: 'CLIENT_ADDRESS_DEPTH',
default: 3
},
signinConfirmation: {
forcedEmailAddresses: {
doc: 'Force sign-in confirmation for email addresses matching this regex.',
format: RegExp,
default: /.+@mozilla\.com$/,
env: 'SIGNIN_CONFIRMATION_FORCE_EMAIL_REGEX'
},
skipForNewAccounts: {
enabled: {
doc: 'Skip sign-in confirmation for newly-created accounts.',
default: true,
env: 'SIGNIN_CONFIRMATION_SKIP_FOR_NEW_ACCOUNTS'
},
maxAge: {
doc: 'Maximum age at which an account is considered "new".',
format: 'duration',
default: '4 hours',
env: 'SIGNIN_CONFIRMATION_MAX_AGE_OF_NEW_ACCOUNTS'
}
},
tokenVerificationCode: {
codeLength: {
doc: 'Number of digits to make up a token code',
default: 6,
env: 'SIGNIN_TOKEN_CODE_LENGTH'
},
codeLifetime: {
doc: 'How long code should be valid for',
format: 'duration',
default: '20 minutes',
env: 'SIGNIN_TOKEN_CODE_LIFETIME'
},
}
},
securityHistory: {
ipProfiling: {
allowedRecency: {
doc: 'Length of time since previously verified event to allow skipping confirmation',
default: '72 hours',
format: 'duration',
env: 'IP_PROFILING_RECENCY'
}
}
},
lastAccessTimeUpdates: {
enabled: {
doc: 'enable updates to the lastAccessTime session token property',
format: Boolean,
default: true,
env: 'LASTACCESSTIME_UPDATES_ENABLED'
},
sampleRate: {
doc: 'sample rate for updates to the lastAccessTime session token property, in the range 0..1',
format: Number,
default: 0.3,
env: 'LASTACCESSTIME_UPDATES_SAMPLE_RATE'
},
earliestSaneTimestamp: {
doc: 'timestamp used as the basis of the fallback value for lastAccessTimeFormatted, currently pinned to the deployment of 1.96.4 / a0940d7dc51e2ba20fa18aa3a830810e35c9a9d9',
format: 'timestamp',
default: 1507081020000,
env: 'LASTACCESSTIME_EARLIEST_SANE_TIMESTAMP'
}
},
signinUnblock: {
codeLength: {
doc: 'Number of alphanumeric digits to make up an unblockCode',
default: 8,
env: 'SIGNIN_UNBLOCK_CODE_LENGTH'
},
codeLifetime: {
doc: 'How long an unblockCode should be valid for',
format: 'duration',
default: '1 hour',
env: 'SIGNIN_UNBLOCK_CODE_LIFETIME'
},
forcedEmailAddresses: {
doc: 'If feature enabled, force sign-in unblock for email addresses matching this regex.',
format: RegExp,
default: '^$', // default is no one
env: 'SIGNIN_UNBLOCK_FORCED_EMAILS'
}
},
hpkpConfig: {
enabled: {
default: false,
doc: 'Feature flag for appending HPKP headers',
format: Boolean,
env: 'HPKP_ENABLE'
},
reportOnly: {
default: true,
doc: 'Enable report only mode',
format: Boolean,
env: 'HPKP_REPORT_ONLY'
},
reportUri: {
default: '',
doc: 'Enable report only mode',
format: String,
env: 'HPKP_REPORT_URI'
},
includeSubDomains: {
default: true,
doc: 'Include Sub-Domains',
format: Boolean,
env: 'HPKP_INCLUDE_SUBDOMAINS'
},
maxAge: {
default: 1,
doc: 'Max age for HPKP headers (seconds)',
format: Number,
env: 'HPKP_MAX_AGE'
},
sha256s: {
default: [],
doc: 'Supported pin-sha256s',
format: Array,
env: 'HPKP_PIN_SHA256'
}
},
push: {
allowedServerRegex: {
doc: 'RegExp that validates the URI format of the Push Server',
format: RegExp,
default: /^https:\/\/[a-zA-Z0-9._-]+(\.services\.mozilla\.com|autopush\.dev\.mozaws\.net|autopush\.stage\.mozaws\.net)(?:\:\d+)?(\/.*)?$/
}
},
pushbox: {
enabled: {
doc: 'Indicates whether talking to the Pushbox server is enabled',
format: Boolean,
default: false,
env: 'PUSHBOX_ENABLED'
},
url: {
doc: 'Pushbox Server URL',
format: 'url',
default: 'https://pushbox.services.mozilla.com/',
env: 'PUSHBOX_URL'
},
key: {
doc: 'Authentication key to use when accessing pushbox server',
format: String,
default: 'Correct_Horse_Battery_Staple_1',
env: 'PUSHBOX_KEY'
},
maxTTL: {
doc: 'Maximum TTL to set on items written to pushbox',
format: 'duration',
default: '28 days',
env: 'PUSHBOX_MAX_TTL'
}
},
sms: {
enabled: {
doc: 'Indicates whether POST /sms is enabled',
default: true,
format: Boolean,
env: 'SMS_ENABLED'
},
useMock: {
doc: 'Use a mock SMS provider implementation, for functional testing',
default: false,
format: Boolean,
env: 'SMS_USE_MOCK'
},
isStatusGeoEnabled: {
doc: 'Indicates whether the status endpoint should do geo-ip lookup',
default: true,
format: Boolean,
env: 'SMS_STATUS_GEO_ENABLED'
},
apiRegion: {
doc: 'AWS region',
default: 'us-east-1',
format: String,
env: 'SMS_API_REGION'
},
countryCodes: {
doc: 'Allow sending SMS to these ISO 3166-1 alpha-2 country codes',
default: ['AT', 'AU', 'BE', 'CA', 'DE', 'DK', 'ES', 'FR', 'GB', 'IT', 'LU', 'NL', 'PT', 'US'],
format: Array,
env: 'SMS_COUNTRY_CODES'
},
installFirefoxLink: {
doc: 'Link for the installFirefox SMS template',
default: 'https://mzl.la/firefoxapp',
format: 'url',
env: 'SMS_INSTALL_FIREFOX_LINK'
},
installFirefoxWithSigninCodeBaseUri: {
doc: 'Base URI for the SMS template when the signinCodes feature is active',
default: 'https://accounts.firefox.com/m',
format: 'url',
env: 'SMS_SIGNIN_CODES_BASE_URI'
},
enableBudgetChecks: {
doc: 'enable checks of the monthly SMS spend against the available budget',
default: true,
format: Boolean,
env: 'SMS_ENABLE_BUDGET_CHECKS'
},
minimumCreditThresholdUSD: {
doc: 'The minimum amount of available credit that is necessary to enable SMS, in US dollars',
default: 200,
format: 'nat',
env: 'SMS_MINIMUM_CREDIT_THRESHOLD'
}
},
secondaryEmail: {
minUnverifiedAccountTime: {
doc: 'The minimum amount of time an account can be unverified before another account can use it for secondary email',
default: '1 day',
format: 'duration',
env: 'SECONDARY_EMAIL_MIN_UNVERIFIED_ACCOUNT_TIME'
}
},
signinCodeSize: {
doc: 'signinCode size in bytes',
default: 6,
format: 'nat',
env: 'SIGNIN_CODE_SIZE'
},
emailStatusPollingTimeout: {
doc: 'how long before emails status polling is considered stale',
default: '1 month',
format: 'duration',
env: 'EMAIL_STATUS_POLLING_TIMEOUT'
},
sentryDsn: {
doc: 'Sentry DSN for error and log reporting',
default: '',
format: 'String',
env: 'SENTRY_DSN'
},
totp: {
serviceName: {
doc: 'Default service name to appear in authenticator',
default: 'Firefox',
format: 'String',
env: 'TOTP_SERVICE_NAME'
},
step: {
doc: 'Default time step size (seconds)',
default: 30,
format: 'nat',
env: 'TOTP_STEP_SIZE'
},
window: {
doc: 'Tokens in the previous x-windows that should be considered valid',
default: 1,
format: 'nat',
env: 'TOTP_WINDOW'
},
recoveryCodes: {
count: {
doc: 'Number of recovery codes to create',
default: 8,
env: 'RECOVERY_CODE_COUNT'
},
notifyLowCount: {
doc: 'Notify the user when there are less than these many recovery codes',
default: 2,
env: 'RECOVERY_CODE_NOTIFY_LOW_COUNT'
}
}
}
})
// handle configuration files. you can specify a CSV list of configuration
// files to process, which will be overlayed in order, in the CONFIG_FILES
// environment variable.
var envConfig = path.join(__dirname, conf.get('env') + '.json')
envConfig = envConfig + ',' + (process.env.CONFIG_FILES || '')
var files = envConfig.split(',').filter(fs.existsSync)
conf.loadFile(files)
conf.validate({ allowed: 'strict' })
// set the public url as the issuer domain for assertions
conf.set('domain', url.parse(conf.get('publicUrl')).host)
// derive fxa-auth-mailer configuration from our content-server url
conf.set('smtp.accountSettingsUrl', conf.get('contentServer.url') + '/settings')
conf.set('smtp.accountRecoveryCodesUrl', conf.get('contentServer.url') + '/settings/two_step_authentication/recovery_codes')
conf.set('smtp.verificationUrl', conf.get('contentServer.url') + '/verify_email')
conf.set('smtp.passwordResetUrl', conf.get('contentServer.url') + '/complete_reset_password')
conf.set('smtp.initiatePasswordResetUrl', conf.get('contentServer.url') + '/reset_password')
conf.set('smtp.initiatePasswordChangeUrl', conf.get('contentServer.url') + '/settings/change_password')
conf.set('smtp.verifyLoginUrl', conf.get('contentServer.url') + '/complete_signin')
conf.set('smtp.reportSignInUrl', conf.get('contentServer.url') + '/report_signin')
conf.set('smtp.revokeAccountRecoveryUrl', conf.get('contentServer.url') + '/settings/account_recovery/confirm_revoke')
conf.set('smtp.createAccountRecoveryUrl', conf.get('contentServer.url') + '/settings/account_recovery/confirm_password')
conf.set('smtp.verifyPrimaryEmailUrl', conf.get('contentServer.url') + '/verify_primary_email')
conf.set('smtp.verifySecondaryEmailUrl', conf.get('contentServer.url') + '/verify_secondary_email')
conf.set('isProduction', conf.get('env') === 'prod')
//sns endpoint is not to be set in production
if (conf.has('snsTopicEndpoint') && conf.get('env') !== 'dev') {
throw new Error('snsTopicEndpoint is only allowed in dev env')
}
if (conf.get('env') === 'dev'){
if (! process.env.AWS_ACCESS_KEY_ID) {
process.env.AWS_ACCESS_KEY_ID = 'DEV_KEY_ID'
}
if (! process.env.AWS_SECRET_ACCESS_KEY) {
process.env.AWS_SECRET_ACCESS_KEY = 'DEV_ACCESS_KEY'
}
}
module.exports = conf