move wellKnownJson to domains
after some more thought: * If app moves to another location, user has to remember to move all this config * It's not really associated with an app. It's to do with the domain info * We can put some hints in the UI if app is missing. part of #703
This commit is contained in:
+33
-23
@@ -1,32 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = exports = {
|
||||
add: add,
|
||||
get: get,
|
||||
getAll: getAll,
|
||||
update: update,
|
||||
del: del,
|
||||
clear: clear,
|
||||
add,
|
||||
get,
|
||||
getAll,
|
||||
update,
|
||||
del,
|
||||
clear,
|
||||
|
||||
fqdn: fqdn,
|
||||
getName: getName,
|
||||
fqdn,
|
||||
getName,
|
||||
|
||||
getDnsRecords: getDnsRecords,
|
||||
upsertDnsRecords: upsertDnsRecords,
|
||||
removeDnsRecords: removeDnsRecords,
|
||||
getDnsRecords,
|
||||
upsertDnsRecords,
|
||||
removeDnsRecords,
|
||||
|
||||
waitForDnsRecord: waitForDnsRecord,
|
||||
waitForDnsRecord,
|
||||
|
||||
removePrivateFields: removePrivateFields,
|
||||
removeRestrictedFields: removeRestrictedFields,
|
||||
removePrivateFields,
|
||||
removeRestrictedFields,
|
||||
|
||||
validateHostname: validateHostname,
|
||||
validateHostname,
|
||||
|
||||
makeWildcard: makeWildcard,
|
||||
makeWildcard,
|
||||
|
||||
parentDomain: parentDomain,
|
||||
parentDomain,
|
||||
|
||||
checkDnsRecords: checkDnsRecords
|
||||
checkDnsRecords
|
||||
};
|
||||
|
||||
var assert = require('assert'),
|
||||
@@ -152,6 +152,12 @@ function validateTlsConfig(tlsConfig, dnsProvider) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function validateWellKnown(wellKnown) {
|
||||
assert.strictEqual(typeof wellKnown, 'object');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function add(domain, data, auditSource, callback) {
|
||||
assert.strictEqual(typeof domain, 'string');
|
||||
assert.strictEqual(typeof data.zoneName, 'string');
|
||||
@@ -246,7 +252,7 @@ function update(domain, data, auditSource, callback) {
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
let { zoneName, provider, config, fallbackCertificate, tlsConfig } = data;
|
||||
let { zoneName, provider, config, fallbackCertificate, tlsConfig, wellKnown } = data;
|
||||
|
||||
if (settings.isDemo() && (domain === settings.adminDomain())) return callback(new BoxError(BoxError.CONFLICT, 'Not allowed in demo mode'));
|
||||
|
||||
@@ -267,6 +273,9 @@ function update(domain, data, auditSource, callback) {
|
||||
error = validateTlsConfig(tlsConfig, provider);
|
||||
if (error) return callback(error);
|
||||
|
||||
error = validateWellKnown(wellKnown, provider);
|
||||
if (error) return callback(error);
|
||||
|
||||
if (provider === domainObject.provider) api(provider).injectPrivateFields(config, domainObject.config);
|
||||
|
||||
verifyDnsConfig(config, domain, zoneName, provider, function (error, sanitizedConfig) {
|
||||
@@ -274,9 +283,10 @@ function update(domain, data, auditSource, callback) {
|
||||
|
||||
let newData = {
|
||||
config: sanitizedConfig,
|
||||
zoneName: zoneName,
|
||||
provider: provider,
|
||||
tlsConfig: tlsConfig
|
||||
zoneName,
|
||||
provider,
|
||||
tlsConfig,
|
||||
wellKnown
|
||||
};
|
||||
|
||||
domaindb.update(domain, newData, function (error) {
|
||||
@@ -431,7 +441,7 @@ function waitForDnsRecord(location, domain, type, value, options, callback) {
|
||||
|
||||
// removes all fields that are strictly private and should never be returned by API calls
|
||||
function removePrivateFields(domain) {
|
||||
var result = _.pick(domain, 'domain', 'zoneName', 'provider', 'config', 'tlsConfig', 'fallbackCertificate');
|
||||
var result = _.pick(domain, 'domain', 'zoneName', 'provider', 'config', 'tlsConfig', 'fallbackCertificate', 'wellKnown');
|
||||
return api(result.provider).removePrivateFields(result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user