Skip to content

Commit

Permalink
added blacklist for authorization header
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleysmithTTD committed Sep 18, 2024
1 parent d4fbb6c commit ae8a26d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
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
3 changes: 2 additions & 1 deletion src/routes/optout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -38,6 +38,7 @@ export async function optout(identityInput: string): Promise<any> {
return axios.post(OPTOUT_ENDPOINT_URL, body,
{
headers: {
Authorization: `Bearer ${OPTOUT_API_KEY}`,
'Content-Type': 'text/plain',
},
});
Expand Down
9 changes: 9 additions & 0 deletions src/utils/logging.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import winston, { createLogger } from 'winston';

Check failure on line 1 in src/utils/logging.ts

View workflow job for this annotation

GitHub Actions / build

Run autofix to sort these imports!

Check failure on line 1 in src/utils/logging.ts

View workflow job for this annotation

GitHub Actions / build

Run autofix to sort these imports!
import expressWinston from 'express-winston';

import { isProduction } from './process';

Expand All @@ -10,4 +11,12 @@ const logger = createLogger({
],
});

const headersToRedact = ['authorization'];

export const getLoggingMiddleware = () =>
expressWinston.logger({

Check failure on line 17 in src/utils/logging.ts

View workflow job for this annotation

GitHub Actions / build

Expected no linebreak before this expression

Check failure on line 17 in src/utils/logging.ts

View workflow job for this annotation

GitHub Actions / build

Expected no linebreak before this expression
winstonInstance: logger,
headerBlacklist: headersToRedact,
});

export default logger;

0 comments on commit ae8a26d

Please sign in to comment.