From d4fbb6c2a7faf75067dcedf447769606ee608f9a Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Tue, 17 Sep 2024 13:49:24 -0600 Subject: [PATCH 1/5] removed authorization header --- src/routes/optout.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/routes/optout.ts b/src/routes/optout.ts index fe6332c..c17af79 100644 --- a/src/routes/optout.ts +++ b/src/routes/optout.ts @@ -2,7 +2,7 @@ import axios from 'axios'; import { Buffer } from 'buffer'; import crypto from 'crypto'; -import { OPTOUT_API_KEY, OPTOUT_API_SECRET, OPTOUT_ENDPOINT_URL } from '../utils/process'; +import { OPTOUT_API_SECRET, OPTOUT_ENDPOINT_URL } from '../utils/process'; interface Optout { phone?: string; @@ -38,7 +38,6 @@ export async function optout(identityInput: string): Promise { return axios.post(OPTOUT_ENDPOINT_URL, body, { headers: { - Authorization: `Bearer ${OPTOUT_API_KEY}`, 'Content-Type': 'text/plain', }, }); From ae8a26d49266a5e17af9e2da0b2746fbf96b55dd Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Wed, 18 Sep 2024 15:04:38 -0600 Subject: [PATCH 2/5] added blacklist for authorization header --- src/app.ts | 4 +++- src/routes/optout.ts | 3 ++- src/utils/logging.ts | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/app.ts b/src/app.ts index b5e3061..9d98e6b 100644 --- a/src/app.ts +++ b/src/app.ts @@ -10,7 +10,7 @@ import winston from 'winston'; import makeMetricsApiMiddleware from './middleware/metrics'; import indexRouter from './routes/index'; -import logger from './utils/logging'; +import logger, { getLoggingMiddleware } from './utils/logging'; import { environment, ID_TYPE, LOCALE_FOLDER, VIEW_FOLDER, } from './utils/process'; @@ -29,6 +29,8 @@ const layoutPath = path.join(viewPath, 'layouts'); app.set('views', viewPath); app.set('view engine', 'hbs'); +app.use(getLoggingMiddleware()); + app.use( makeMetricsApiMiddleware({ port: 9082, diff --git a/src/routes/optout.ts b/src/routes/optout.ts index c17af79..fe6332c 100644 --- a/src/routes/optout.ts +++ b/src/routes/optout.ts @@ -2,7 +2,7 @@ import axios from 'axios'; import { Buffer } from 'buffer'; import crypto from 'crypto'; -import { OPTOUT_API_SECRET, OPTOUT_ENDPOINT_URL } from '../utils/process'; +import { OPTOUT_API_KEY, OPTOUT_API_SECRET, OPTOUT_ENDPOINT_URL } from '../utils/process'; interface Optout { phone?: string; @@ -38,6 +38,7 @@ export async function optout(identityInput: string): Promise { return axios.post(OPTOUT_ENDPOINT_URL, body, { headers: { + Authorization: `Bearer ${OPTOUT_API_KEY}`, 'Content-Type': 'text/plain', }, }); diff --git a/src/utils/logging.ts b/src/utils/logging.ts index f7b4424..2730876 100644 --- a/src/utils/logging.ts +++ b/src/utils/logging.ts @@ -1,4 +1,5 @@ import winston, { createLogger } from 'winston'; +import expressWinston from 'express-winston'; import { isProduction } from './process'; @@ -10,4 +11,12 @@ const logger = createLogger({ ], }); +const headersToRedact = ['authorization']; + +export const getLoggingMiddleware = () => + expressWinston.logger({ + winstonInstance: logger, + headerBlacklist: headersToRedact, + }); + export default logger; From 17ec55146963ee3215d3d490be42583d49bd962b Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Wed, 18 Sep 2024 15:07:03 -0600 Subject: [PATCH 3/5] fixed order of imports --- src/utils/logging.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/logging.ts b/src/utils/logging.ts index 2730876..275f4c8 100644 --- a/src/utils/logging.ts +++ b/src/utils/logging.ts @@ -1,5 +1,5 @@ -import winston, { createLogger } from 'winston'; import expressWinston from 'express-winston'; +import winston, { createLogger } from 'winston'; import { isProduction } from './process'; From 9be51efbcf8fdab185e96555241239d465828428 Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Wed, 18 Sep 2024 15:15:16 -0600 Subject: [PATCH 4/5] lint fix --- src/utils/logging.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils/logging.ts b/src/utils/logging.ts index 275f4c8..a4e4dbb 100644 --- a/src/utils/logging.ts +++ b/src/utils/logging.ts @@ -13,8 +13,7 @@ const logger = createLogger({ const headersToRedact = ['authorization']; -export const getLoggingMiddleware = () => - expressWinston.logger({ +export const getLoggingMiddleware = () => expressWinston.logger({ winstonInstance: logger, headerBlacklist: headersToRedact, }); From 2f10790a6351f1cc22ced06241a0fcdc42c686cc Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Wed, 18 Sep 2024 15:16:34 -0600 Subject: [PATCH 5/5] lint fix --- src/utils/logging.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/logging.ts b/src/utils/logging.ts index a4e4dbb..162180d 100644 --- a/src/utils/logging.ts +++ b/src/utils/logging.ts @@ -14,8 +14,8 @@ const logger = createLogger({ const headersToRedact = ['authorization']; export const getLoggingMiddleware = () => expressWinston.logger({ - winstonInstance: logger, - headerBlacklist: headersToRedact, - }); + winstonInstance: logger, + headerBlacklist: headersToRedact, +}); export default logger;