Skip to content

Commit

Permalink
Add faker for backend openshift user
Browse files Browse the repository at this point in the history
  • Loading branch information
lucferbux committed Dec 15, 2022
1 parent 1a238f7 commit b8f007d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions backend/src/utils/userUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FastifyRequest } from 'fastify';
import * as _ from 'lodash';
import { USER_ACCESS_TOKEN } from './constants';
import { DEV_TOKEN_AUTH, USER_ACCESS_TOKEN } from './constants';
import { KubeFastifyInstance } from '../types';
import { DEV_MODE } from './constants';
import { createCustomError } from './requestUtils';
Expand Down Expand Up @@ -55,14 +55,18 @@ export const getUser = async (
fastify: KubeFastifyInstance,
request: FastifyRequest,
): Promise<OpenShiftUser> => {
const accessToken = request.headers[USER_ACCESS_TOKEN] as string;
let accessToken = request.headers[USER_ACCESS_TOKEN] as string;
if (!accessToken) {
const error = createCustomError(
'Unauthorized',
`Error, missing x-forwarded-access-token header`,
401,
);
throw error;
if(DEV_TOKEN_AUTH){
accessToken = DEV_TOKEN_AUTH;
} else {
const error = createCustomError(
'Unauthorized',
`Error, missing x-forwarded-access-token header`,
401,
);
throw error;
}
}
try {
const customObjectApiNoAuth = _.cloneDeep(fastify.kube.customObjectsApi);
Expand Down

0 comments on commit b8f007d

Please sign in to comment.