57 basic auth dev only (#58)
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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"]
|
||||||
|
|||||||
@@ -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
@@ -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');
|
||||||
|
|||||||
Reference in New Issue
Block a user