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

View File

@ -80,12 +80,20 @@ export async function initializeConfiguration(): Promise<ConfigContext> {
console.error(error); 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); const params = new URLSearchParams(window.location.search);
params.forEach((value, key) => { if (params.has("platform")) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any const platform = params.get("platform");
(configContext as any)[key] = value; 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) { } catch (error) {
console.log("No configuration file found using defaults"); console.log("No configuration file found using defaults");
} }