Allow 'platform' only to be overriden (#167)

ConfigContext defines all kinds of URLs and what not, I'm not
sure about the security implications of allowing all this stuff to
be modifiable by just anyone.
This commit is contained in:
Jordi Bunster 2020-08-25 22:48:58 -07:00 committed by GitHub
parent 3223ff7685
commit 5c84b3a7d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 5 deletions

View File

@ -80,12 +80,20 @@ export async function initializeConfiguration(): Promise<ConfigContext> {
console.error(error);
}
}
// Allow override of any config value with URL query parameters
// Allow override of platform value with URL query parameter
const params = new URLSearchParams(window.location.search);
params.forEach((value, key) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(configContext as any)[key] = value;
});
if (params.has("platform")) {
const platform = params.get("platform");
switch (platform) {
default:
console.log("Invalid platform query parameter given, ignoring");
break;
case Platform.Portal:
case Platform.Hosted:
case Platform.Emulator:
updateConfigContext({ platform });
}
}
} catch (error) {
console.log("No configuration file found using defaults");
}