Validate endpoints from feature flags (#1196)

Validate endpoints from feature flags
This commit is contained in:
Armando Trejo Oliver
2022-01-24 13:06:43 -08:00
committed by GitHub
parent de5df90f75
commit f5da8bb276
10 changed files with 178 additions and 59 deletions

View File

@@ -1,4 +1,5 @@
import ko from "knockout";
import { allowedJunoOrigins, validateEndpoint } from "Utils/EndpointValidation";
import { GetGithubClientId } from "Utils/GitHubUtils";
import { HttpHeaders, HttpStatusCodes } from "../Common/Constants";
import { configContext } from "../ConfigContext";
@@ -484,7 +485,7 @@ export class JunoClient {
// public for tests
public static getJunoEndpoint(): string {
const junoEndpoint = userContext.features.junoEndpoint ?? configContext.JUNO_ENDPOINT;
if (configContext.allowedJunoOrigins.indexOf(new URL(junoEndpoint).origin) === -1) {
if (!validateEndpoint(junoEndpoint, allowedJunoOrigins)) {
const error = `${junoEndpoint} not allowed as juno endpoint`;
console.error(error);
throw new Error(error);