2013-07-26 05:46:16 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2015-05-13 03:48:26 +03:00
|
|
|
require('envc')()
|
|
|
|
|
2013-07-23 22:16:44 +04:00
|
|
|
var fs = require('fs')
|
|
|
|
var path = require('path')
|
|
|
|
var url = require('url')
|
|
|
|
var convict = require('convict')
|
2015-05-10 22:11:59 +03:00
|
|
|
var DEFAULT_SUPPORTED_LANGUAGES = require('./supportedLanguages')
|
2013-07-23 22:16:44 +04:00
|
|
|
|
2015-05-10 22:11:59 +03:00
|
|
|
var conf = convict({
|
|
|
|
env: {
|
2015-06-19 02:12:42 +03:00
|
|
|
doc: 'The current node.js environment',
|
|
|
|
default: 'prod',
|
|
|
|
format: [ 'dev', 'test', 'stage', 'prod' ],
|
2015-05-10 22:11:59 +03:00
|
|
|
env: 'NODE_ENV'
|
|
|
|
},
|
|
|
|
log: {
|
|
|
|
level: {
|
|
|
|
default: 'info',
|
|
|
|
env: 'LOG_LEVEL'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
publicUrl: {
|
2015-06-19 02:12:42 +03:00
|
|
|
format: 'url',
|
2015-05-10 22:11:59 +03:00
|
|
|
// the real url is set by awsbox
|
2015-06-19 02:12:42 +03:00
|
|
|
default: 'http://127.0.0.1:9000',
|
|
|
|
env: 'PUBLIC_URL'
|
2015-05-10 22:11:59 +03:00
|
|
|
},
|
2015-06-10 04:36:32 +03:00
|
|
|
domain: {
|
2015-06-19 02:12:42 +03:00
|
|
|
format: 'url',
|
|
|
|
doc: 'Derived automatically from publicUrl',
|
2015-06-10 04:36:32 +03:00
|
|
|
default: undefined
|
|
|
|
},
|
2015-05-10 22:11:59 +03:00
|
|
|
secretKeyFile: {
|
2015-05-13 03:48:26 +03:00
|
|
|
format: String,
|
|
|
|
default: path.resolve(__dirname, '../config/secret-key.json'),
|
|
|
|
env: 'SECRET_KEY_FILE'
|
2015-05-10 22:11:59 +03:00
|
|
|
},
|
|
|
|
publicKeyFile: {
|
2015-05-13 03:48:26 +03:00
|
|
|
format: String,
|
|
|
|
default: path.resolve(__dirname, '../config/public-key.json'),
|
|
|
|
env: 'PUBLIC_KEY_FILE'
|
2015-05-10 22:11:59 +03:00
|
|
|
},
|
|
|
|
trustedJKUs: {
|
2015-05-13 03:48:26 +03:00
|
|
|
format: Array,
|
|
|
|
default: [],
|
|
|
|
env: 'TRUSTED_JKUS'
|
2015-05-10 22:11:59 +03:00
|
|
|
},
|
|
|
|
db: {
|
|
|
|
backend: {
|
2015-06-19 02:12:42 +03:00
|
|
|
default: 'httpdb',
|
2015-05-10 22:11:59 +03:00
|
|
|
env: 'DB_BACKEND'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
httpdb: {
|
|
|
|
url: {
|
|
|
|
doc: 'database api url',
|
2015-05-13 03:48:26 +03:00
|
|
|
default: 'http://127.0.0.1:8000',
|
|
|
|
env: 'HTTPDB_URL'
|
2015-05-10 22:11:59 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
listen: {
|
|
|
|
host: {
|
2015-06-19 02:12:42 +03:00
|
|
|
doc: 'The ip address the server should bind',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: '127.0.0.1',
|
|
|
|
format: 'ipaddress',
|
|
|
|
env: 'IP_ADDRESS'
|
|
|
|
},
|
|
|
|
port: {
|
2015-06-19 02:12:42 +03:00
|
|
|
doc: 'The port the server should bind',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: 9000,
|
|
|
|
format: 'port',
|
|
|
|
env: 'PORT'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
customsUrl: {
|
2015-06-19 02:12:42 +03:00
|
|
|
doc: 'fraud / abuse server url',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: 'http://127.0.0.1:7000',
|
|
|
|
env: 'CUSTOMS_SERVER_URL'
|
|
|
|
},
|
|
|
|
contentServer: {
|
|
|
|
url: {
|
2015-06-19 02:12:42 +03:00
|
|
|
doc: 'The url of the corresponding fxa-content-server instance',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: 'http://127.0.0.1:3030',
|
|
|
|
env: 'CONTENT_SERVER_URL'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
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'
|
|
|
|
},
|
|
|
|
verificationUrl: {
|
|
|
|
doc: 'Deprecated. uses contentServer.url',
|
|
|
|
format: String,
|
|
|
|
default: undefined,
|
|
|
|
env: 'VERIFY_URL',
|
|
|
|
arg: 'verify-url'
|
|
|
|
},
|
|
|
|
passwordResetUrl: {
|
|
|
|
doc: 'Deprecated. uses contentServer.url',
|
|
|
|
format: String,
|
|
|
|
default: undefined,
|
|
|
|
env: 'RESET_URL',
|
|
|
|
arg: 'reset-url'
|
|
|
|
},
|
2015-06-10 04:36:32 +03:00
|
|
|
accountUnlockUrl: {
|
|
|
|
doc: 'Deprecated. uses contentServer.url',
|
|
|
|
format: String,
|
|
|
|
default: undefined,
|
|
|
|
env: 'UNLOCK_URL',
|
|
|
|
arg: 'unlock-url'
|
|
|
|
},
|
2015-02-22 15:43:01 +03:00
|
|
|
initiatePasswordResetUrl: {
|
|
|
|
doc: 'Deprecated. uses contentServer.url',
|
|
|
|
format: String,
|
|
|
|
default: undefined
|
|
|
|
},
|
2015-05-10 22:11:59 +03:00
|
|
|
redirectDomain: {
|
|
|
|
doc: 'Domain that mail urls are allowed to redirect to',
|
|
|
|
format: String,
|
2015-05-13 03:48:26 +03:00
|
|
|
default: 'firefox.com',
|
|
|
|
env: 'REDIRECT_DOMAIN'
|
2015-05-10 22:11:59 +03:00
|
|
|
},
|
|
|
|
resendBlackoutPeriod: {
|
2015-07-14 19:37:14 +03:00
|
|
|
doc: 'Blackout period for resending verification emails (milliseconds)',
|
|
|
|
format: 'duration',
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'RESEND_BLACKOUT_PERIOD',
|
2015-07-14 19:37:14 +03:00
|
|
|
default: '10 minutes'
|
2015-05-10 22:11:59 +03:00
|
|
|
}
|
|
|
|
},
|
2015-05-20 08:09:01 +03:00
|
|
|
maxEventLoopDelay: {
|
2015-06-19 02:12:42 +03:00
|
|
|
doc: 'Max event-loop delay before which incoming requests are rejected',
|
2015-05-20 08:09:01 +03:00
|
|
|
default: 0,
|
|
|
|
env: 'MAX_EVENT_LOOP_DELAY'
|
2015-05-10 22:11:59 +03:00
|
|
|
},
|
|
|
|
scrypt: {
|
|
|
|
maxPending: {
|
2015-06-19 02:12:42 +03:00
|
|
|
doc: 'Max number of scrypt hash operations that can be pending',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: 0,
|
|
|
|
env: 'SCRYPT_MAX_PENDING'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
i18n: {
|
|
|
|
defaultLanguage: {
|
|
|
|
format: String,
|
2015-05-13 03:48:26 +03:00
|
|
|
default: 'en',
|
|
|
|
env: 'DEFAULT_LANG'
|
2015-05-10 22:11:59 +03:00
|
|
|
},
|
|
|
|
supportedLanguages: {
|
2015-05-13 03:48:26 +03:00
|
|
|
format: Array,
|
|
|
|
default: DEFAULT_SUPPORTED_LANGUAGES,
|
|
|
|
env: 'SUPPORTED_LANGS'
|
2015-05-10 22:11:59 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
tokenLifetimes: {
|
|
|
|
accountResetToken: {
|
2015-07-14 19:37:14 +03:00
|
|
|
format: 'duration',
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'ACCOUNT_RESET_TOKEN_TTL',
|
2015-07-14 19:37:14 +03:00
|
|
|
default: '15 minutes'
|
2015-05-10 22:11:59 +03:00
|
|
|
},
|
|
|
|
passwordForgotToken: {
|
2015-07-14 19:37:14 +03:00
|
|
|
format: 'duration',
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'PASSWORD_FORGOT_TOKEN_TTL',
|
2015-07-14 19:37:14 +03:00
|
|
|
default: '60 minutes'
|
2015-05-10 22:11:59 +03:00
|
|
|
},
|
|
|
|
passwordChangeToken: {
|
2015-07-14 19:37:14 +03:00
|
|
|
format: 'duration',
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'PASSWORD_CHANGE_TOKEN_TTL',
|
2015-07-14 19:37:14 +03:00
|
|
|
default: '15 minutes'
|
2015-05-10 22:11:59 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
verifierVersion: {
|
|
|
|
doc: 'verifer version for new and changed passwords',
|
2015-05-13 03:48:26 +03:00
|
|
|
format: 'int',
|
|
|
|
env: 'VERIFIER_VERSION',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: 1
|
|
|
|
},
|
|
|
|
snsTopicArn: {
|
|
|
|
doc: 'Amazon SNS topic on which to send account event notifications. Set to "disabled" to turn off the notifier',
|
|
|
|
format: String,
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'SNS_TOPIC_ARN',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
bounces: {
|
|
|
|
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,
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'BOUNCE_REGION',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
bounceQueueUrl: {
|
|
|
|
doc: 'The bounce queue URL to use (should include https://sqs.<region>.amazonaws.com/<account-id>/<queue-name>)',
|
|
|
|
format: String,
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'BOUNCE_QUEUE_URL',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
complaintQueueUrl: {
|
|
|
|
doc: 'The complaint queue URL to use (should include https://sqs.<region>.amazonaws.com/<account-id>/<queue-name>)',
|
|
|
|
format: String,
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'COMPLAINT_QUEUE_URL',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
basket: {
|
|
|
|
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,
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'BASKET_REGION',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
apiUrl: {
|
|
|
|
doc: 'Url for the Basket API server',
|
|
|
|
format: String,
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'BASKET_API_URL',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
apiKey: {
|
|
|
|
doc: 'Basket API key',
|
|
|
|
format: String,
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'BASKET_API_KEY',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
queueUrl: {
|
|
|
|
doc: 'The bounce queue URL',
|
|
|
|
format: String,
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'BASKET_QUEUE_URL',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
useHttps: {
|
2015-06-19 02:12:42 +03:00
|
|
|
doc: 'set to true to serve directly over https',
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'USE_TLS',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: false
|
|
|
|
},
|
|
|
|
keyPath: {
|
2015-06-19 02:12:42 +03:00
|
|
|
doc: 'path to SSL key in PEM format if serving over https',
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'TLS_KEY_PATH',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: path.resolve(__dirname, '../key.pem')
|
|
|
|
},
|
|
|
|
certPath: {
|
2015-06-19 02:12:42 +03:00
|
|
|
doc: 'path to SSL certificate in PEM format if serving over https',
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'TLS_CERT_PATH',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: path.resolve(__dirname, '../cert.pem')
|
|
|
|
},
|
|
|
|
lockoutEnabled: {
|
|
|
|
doc: 'Is account lockout enabled',
|
|
|
|
format: Boolean,
|
2015-05-13 03:48:26 +03:00
|
|
|
env: 'LOCKOUT_ENABLED',
|
2015-05-10 22:11:59 +03:00
|
|
|
default: false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// handle configuration files. you can specify a CSV list of configuration
|
|
|
|
// files to process, which will be overlayed in order, in the CONFIG_FILES
|
2015-05-13 03:48:26 +03:00
|
|
|
// environment variable.
|
2015-05-10 22:11:59 +03:00
|
|
|
|
2015-05-13 03:48:26 +03:00
|
|
|
var files = (process.env.CONFIG_FILES || '').split(',').filter(fs.existsSync)
|
2015-05-10 22:11:59 +03:00
|
|
|
conf.loadFile(files)
|
|
|
|
|
|
|
|
// 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.verificationUrl', conf.get('contentServer.url') + '/v1/verify_email')
|
|
|
|
conf.set('smtp.passwordResetUrl', conf.get('contentServer.url') + '/v1/complete_reset_password')
|
|
|
|
conf.set('smtp.accountUnlockUrl', conf.get('contentServer.url') + '/v1/complete_unlock_account')
|
2015-02-22 15:43:01 +03:00
|
|
|
conf.set('smtp.initiatePasswordResetUrl', conf.get('contentServer.url') + '/v1/reset_password')
|
2015-05-10 22:11:59 +03:00
|
|
|
|
2015-06-10 04:36:32 +03:00
|
|
|
var options = {
|
|
|
|
strict: true
|
|
|
|
}
|
|
|
|
|
|
|
|
conf.validate(options)
|
2015-05-10 22:11:59 +03:00
|
|
|
|
|
|
|
module.exports = conf
|