Skip to content

Commit

Permalink
misc: mask jwt from log (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
embbnux committed Mar 20, 2024
1 parent f4f43e7 commit 3814c04
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ const { botHandler } = require('./bot/handler');
const { botConfig } = require('./bot/config');

const app = express()
app.use(morgan('tiny'))
app.use(morgan(function (tokens, req, res) {
let url = tokens.url(req, res);
if (url.indexOf('/bot-notify/') === 0) {
url = `/bot-notify/[MASK]-${url.slice(-5)}`; // mask from log
}
return [
tokens.method(req, res),
url,
tokens.status(req, res),
tokens.res(req, res, 'content-length'), '-',
tokens['response-time'](req, res), 'ms'
].join(' ');
}));
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

Expand Down

0 comments on commit 3814c04

Please sign in to comment.