Skip to content

Commit

Permalink
Merge pull request #76 from IABTechLab/ans-UID2-3670-prevent-tcportal…
Browse files Browse the repository at this point in the history
…-logging-full-request-content

Prevent tcportal logging full request content with authorization
  • Loading branch information
ashleysmithTTD authored Sep 18, 2024
2 parents 4230765 + 2f10790 commit 594e6b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/utils/logging.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import expressWinston from 'express-winston';
import winston, { createLogger } from 'winston';

import { isProduction } from './process';
Expand All @@ -10,4 +11,11 @@ const logger = createLogger({
],
});

const headersToRedact = ['authorization'];

export const getLoggingMiddleware = () => expressWinston.logger({
winstonInstance: logger,
headerBlacklist: headersToRedact,
});

export default logger;

0 comments on commit 594e6b7

Please sign in to comment.