57 basic auth dev only (#58)

This commit is contained in:
Anders Gustafsson
2021-09-29 10:43:51 +02:00
committed by GitHub
parent e5aa1486e3
commit a270d0d523
4 changed files with 8 additions and 3 deletions
+2
View File
@@ -6,6 +6,8 @@ EXPOSE 4000
COPY . app/ COPY . app/
# Changes working directory to the new directory just created # Changes working directory to the new directory just created
WORKDIR /app WORKDIR /app
# Set node env
ENV NODE_ENV=production
# Installs npm dependencies on container # Installs npm dependencies on container
RUN npm ci RUN npm ci
# Command container will actually run when called # Command container will actually run when called
+2
View File
@@ -5,5 +5,7 @@ FROM node:14.17.0
EXPOSE 4000 EXPOSE 4000
# Changes working directory to the new directory just created # Changes working directory to the new directory just created
WORKDIR /app WORKDIR /app
# Set node env
ENV NODE_ENV=development
# Command container will actually run when called # Command container will actually run when called
CMD ["npx", "nodemon", "-w", "src", "--ext", "ts", "--exec", "ts-node", "src/index.ts"] CMD ["npx", "nodemon", "-w", "src", "--ext", "ts", "--exec", "ts-node", "src/index.ts"]
-1
View File
@@ -107,7 +107,6 @@ const verifyToken = async (
request: ClaimVerifyRequest, request: ClaimVerifyRequest,
): Promise<ClaimVerifyResult> => { ): Promise<ClaimVerifyResult> => {
try { try {
// console.log(`user claim verify invoked for ${JSON.stringify(request)}`);
const token = request.token; const token = request.token;
const tokenSections = (token || '').split('.'); const tokenSections = (token || '').split('.');
if (tokenSections.length < 2) { if (tokenSections.length < 2) {
+4 -2
View File
@@ -59,8 +59,10 @@ const context = async ({ req }) => {
const token = authHeader.substring(7, authHeader.length); const token = authHeader.substring(7, authHeader.length);
const res = await verifyToken({ token }); const res = await verifyToken({ token });
return { auth: res }; return { auth: res };
} else if (authHeader == 'Basic ZGV2OmRldg==') { } else if (
// dev:dev remove later process.env.NODE_ENV === 'development' &&
authHeader == 'Basic ZGV2OnB2N1VmYSFiZVAzeGk='
) {
return { auth: 'during development' }; return { auth: 'during development' };
} }
throw new AuthenticationError('Not authorized'); throw new AuthenticationError('Not authorized');