Skip to content

Commit

Permalink
Standardized on hostAllowList
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwiupover committed Jun 11, 2021
1 parent d61b516 commit c939b82
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,23 +273,23 @@ module.exports = function(environment) {
},

fastboot: {
hostAllowlist: ['example.com', 'subdomain.example.com', /^localhost:\d+$/]
hostAllowList: ['example.com', 'subdomain.example.com', /^localhost:\d+$/]
}
};
// ...
};
```

The `hostAllowlist` can be a string or RegExp to match multiple hosts.
The `hostAllowList` can be a string or RegExp to match multiple hosts.
Care should be taken when using a RegExp, as the host function relies on
the `Host` HTTP header, which can be forged. You could potentially allow
a malicious request if your RegExp is too permissive when using the `host`
when making subsequent requests.

Retrieving `host` will error on 2 conditions:

1. you do not have a `hostAllowlist` defined
2. the `Host` header does not match an entry in your `hostAllowlist`
1. you do not have a `hostAllowList` defined
2. the `Host` header does not match an entry in your `hostAllowList`

### Query Parameters

Expand Down
2 changes: 1 addition & 1 deletion packages/ember-cli-fastboot/fastboot/initializers/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var nodeAjax = function(options) {
try {
options.url = protocol + '//' + get(this, 'fastboot.request.host') + options.url;
} catch (fbError) {
throw new Error('You are using Ember Data with no host defined in your adapter. This will attempt to use the host of the FastBoot request, which is not configured for the current host of this request. Please set the hostAllowlist property for in your environment.js. FastBoot Error: ' + fbError.message);
throw new Error('You are using Ember Data with no host defined in your adapter. This will attempt to use the host of the FastBoot request, which is not configured for the current host of this request. Please set the hostAllowList property for in your environment.js. FastBoot Error: ' + fbError.message);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ module.exports = class FastBootConfig extends Plugin {
buildHostAllowList() {
if (this.fastbootAppConfig) {
if ('hostWhitelist' in this.fastbootAppConfig) {
this.ui.writeLine('Please update your fastboot config to use `hostAllowList` of the deprecated `hostWhitelist`');
this.ui.writeLine('Please update your fastboot config to use `hostAllowList` instead of the deprecated `hostWhitelist`');
}
this.hostAllowList = this.fastbootAppConfig.hostAllowList || this.fastbootAppConfig.hostWhitelist
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-cli-fastboot/test/fastboot-config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ describe('FastbootConfig', function() {
'package.json': `{"dependencies":{},"fastboot":{"appName":"app","config":{"app":{"modulePrefix":"app"}},"hostAllowList":["example.com","subdomain.example.com"],"manifest":{"appFiles":["app.js","app-fastboot.js"],"htmlFile":"index.html","vendorFiles":["vendor.js"]},"moduleAllowlist":[],"schemaVersion":3}}`
});

expect(output.builder.outputNode.ui.output).to.contain('Please update your fastboot config to use `hostAllowList` of the deprecated `hostWhitelist`');
expect(output.builder.outputNode.ui.output).to.contain('Please update your fastboot config to use `hostAllowList` instead of the deprecated `hostWhitelist`');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function(environment) {
},

fastboot: {
hostAllowlist: ['example.com', 'subdomain.example.com', /localhost:\d+/]
hostAllowList: ['example.com', 'subdomain.example.com', /localhost:\d+/]
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function(environment) {
modulePrefix: 'fastboot-location-config',
fastboot: {
fastbootHeaders: false,
hostAllowlist: [/localhost:\d+/],
hostAllowList: [/localhost:\d+/],
redirectCode: 302,
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function(environment) {
modulePrefix: 'fastboot-location',
fastboot: {
fastbootHeaders: true,
hostAllowlist: [/localhost:\d+/]
hostAllowList: [/localhost:\d+/]
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function(environment) {
},

fastboot: {
hostAllowlist: ['example.com', 'subdomain.example.com', /localhost:\d+/]
hostAllowList: ['example.com', 'subdomain.example.com', /localhost:\d+/]
}
};

Expand Down
4 changes: 2 additions & 2 deletions test-packages/basic-app/test/package-json-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe("generating package.json", function () {
it("contains a list of allowed hosts from environment.js", function () {
let pkg = fs.readJSONSync("dist/package.json");

expect(pkg.fastboot.hostAllowlist).to.deep.equal([
expect(pkg.fastboot.hostAllowList).to.deep.equal([
"example.com",
"subdomain.example.com",
"/localhost:\\d+/",
Expand Down Expand Up @@ -117,7 +117,7 @@ describe("generating package.json", function () {
autoboot: false,
},
fastboot: {
hostAllowlist: [
hostAllowList: [
"example.com",
"subdomain.example.com",
"/localhost:\\d+/",
Expand Down

0 comments on commit c939b82

Please sign in to comment.