forked from OpenNeo/impress
Emi Matchu
4fff8d88f2
A little architecture trick here! DTI 2020 authorizes support staff requests by means of a secret token, instead of user account stuff. And our support tools still all call DTI 2020 APIs. So here, we bridge the gap: we copy DTI 2020's support secret to this app's environment variables (I needed to update `deploy/files/production.env` and run `bin/deploy:setup` for this!), then users with the new `support_secret` flag have it added to their HTML documents in the meta tags. Then, the JS reads the meta tag. I also fixed an issue in the `deploy/setup.yml` playbook, where I had temporarily commented some stuff out to skip steps one time, and forgot to uncomment them after oops lol!
20 lines
530 B
JavaScript
20 lines
530 B
JavaScript
const ORIGIN = readOrigin();
|
|
const SUPPORT_SECRET = readSupportSecret();
|
|
|
|
export function buildImpress2020Url(path) {
|
|
return new URL(path, ORIGIN).toString();
|
|
}
|
|
|
|
export function getSupportSecret() {
|
|
return SUPPORT_SECRET;
|
|
}
|
|
|
|
function readOrigin() {
|
|
const node = document.querySelector("meta[name=impress-2020-origin]");
|
|
return node?.content || "https://impress-2020.openneo.net"
|
|
}
|
|
|
|
function readSupportSecret() {
|
|
const node = document.querySelector("meta[name=impress-2020-support-secret]");
|
|
return node?.content || null;
|
|
}
|