57 basic auth dev only (#58)
This commit is contained in:
@@ -6,6 +6,8 @@ EXPOSE 4000
|
||||
COPY . app/
|
||||
# Changes working directory to the new directory just created
|
||||
WORKDIR /app
|
||||
# Set node env
|
||||
ENV NODE_ENV=production
|
||||
# Installs npm dependencies on container
|
||||
RUN npm ci
|
||||
# Command container will actually run when called
|
||||
|
||||
@@ -5,5 +5,7 @@ FROM node:14.17.0
|
||||
EXPOSE 4000
|
||||
# Changes working directory to the new directory just created
|
||||
WORKDIR /app
|
||||
# Set node env
|
||||
ENV NODE_ENV=development
|
||||
# Command container will actually run when called
|
||||
CMD ["npx", "nodemon", "-w", "src", "--ext", "ts", "--exec", "ts-node", "src/index.ts"]
|
||||
|
||||
@@ -107,7 +107,6 @@ const verifyToken = async (
|
||||
request: ClaimVerifyRequest,
|
||||
): Promise<ClaimVerifyResult> => {
|
||||
try {
|
||||
// console.log(`user claim verify invoked for ${JSON.stringify(request)}`);
|
||||
const token = request.token;
|
||||
const tokenSections = (token || '').split('.');
|
||||
if (tokenSections.length < 2) {
|
||||
|
||||
+4
-2
@@ -59,8 +59,10 @@ const context = async ({ req }) => {
|
||||
const token = authHeader.substring(7, authHeader.length);
|
||||
const res = await verifyToken({ token });
|
||||
return { auth: res };
|
||||
} else if (authHeader == 'Basic ZGV2OmRldg==') {
|
||||
// dev:dev remove later
|
||||
} else if (
|
||||
process.env.NODE_ENV === 'development' &&
|
||||
authHeader == 'Basic ZGV2OnB2N1VmYSFiZVAzeGk='
|
||||
) {
|
||||
return { auth: 'during development' };
|
||||
}
|
||||
throw new AuthenticationError('Not authorized');
|
||||
|
||||
Reference in New Issue
Block a user