0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Renamed whitelist -> allowlist

no issue

- Renames to follow the naming convention from https://mysqlhighavailability.com/mysql-terminology-updates/
This commit is contained in:
Naz 2021-11-08 16:09:19 +04:00
parent f0242baf9f
commit 92986b77e3

View file

@ -3,7 +3,7 @@ const url = require('url');
const os = require('os');
const urlUtils = require('../../../../shared/url-utils');
let whitelist = [];
let allowlist = [];
const ENABLE_CORS = {origin: true, maxAge: 86400};
const DISABLE_CORS = {origin: false};
@ -46,16 +46,16 @@ function getUrls() {
return urls;
}
function getWhitelist() {
function getAllowlist() {
// This needs doing just one time after init
if (whitelist.length === 0) {
if (allowlist.length === 0) {
// origins that always match: localhost, local IPs, etc.
whitelist = whitelist.concat(getIPs());
allowlist = allowlist.concat(getIPs());
// Trusted urls from config.js
whitelist = whitelist.concat(getUrls());
allowlist = allowlist.concat(getUrls());
}
return whitelist;
return allowlist;
}
/**
@ -73,7 +73,7 @@ function handleCORS(req, cb) {
}
// Origin matches whitelist
if (getWhitelist().indexOf(url.parse(origin).hostname) > -1) {
if (getAllowlist().indexOf(url.parse(origin).hostname) > -1) {
return cb(null, ENABLE_CORS);
}