Skip to content

Commit

Permalink
Allow override of the path to oauth for impersonate user
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-phillips-18 committed Jan 14, 2025
1 parent ebc2c66 commit 552ecf1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/src/routes/api/dev-impersonate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import https from 'https';
import createError from 'http-errors';
import { setImpersonateAccessToken } from '../../../devFlags';
import { KubeFastifyInstance } from '../../../types';
import { DEV_IMPERSONATE_PASSWORD, DEV_IMPERSONATE_USER } from '../../../utils/constants';
import {
DEV_IMPERSONATE_PASSWORD,
DEV_IMPERSONATE_USER,
DEV_OATH_PREFIX,
} from '../../../utils/constants';
import { createCustomError } from '../../../utils/requestUtils';
import { devRoute } from '../../../utils/route-security';

Expand All @@ -16,7 +20,7 @@ export default async (fastify: KubeFastifyInstance): Promise<void> => {
if (doImpersonate) {
const apiPath = fastify.kube.config.getCurrentCluster().server;
const namedHost = apiPath.slice('https://api.'.length).split(':')[0];
const url = `https://oauth-openshift.apps.${namedHost}/oauth/authorize?response_type=token&client_id=openshift-challenging-client`;
const url = `https://${DEV_OATH_PREFIX}.${namedHost}/oauth/authorize?response_type=token&client_id=openshift-challenging-client`;
// Custom call, don't use proxy
const httpsRequest = https
.get(
Expand Down
1 change: 1 addition & 0 deletions backend/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const DEV_MODE = process.env.APP_ENV === 'development';
/** Allows a username to be impersonated in place of the logged in user for testing purposes -- impacts only some API */
export const DEV_IMPERSONATE_USER = DEV_MODE ? process.env.DEV_IMPERSONATE_USER : undefined;
export const DEV_IMPERSONATE_PASSWORD = DEV_MODE ? process.env.DEV_IMPERSONATE_PASSWORD : undefined;
export const DEV_OATH_PREFIX = process.env.DEV_OAUTH_PREFIX || 'oauth-openshift.apps';
export const APP_ENV = process.env.APP_ENV;

export const USER_ACCESS_TOKEN = 'x-forwarded-access-token';
Expand Down

0 comments on commit 552ecf1

Please sign in to comment.