Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
s4ke committed Nov 12, 2023
1 parent e107f9e commit 317240b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions docker-swarm-multitenant-proxy/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ function isVolumeDriverAllowed(volumeDriver: string): boolean {

export const app = express();

if(!TLS_DISABLED) {
morgan.token('client-cn', (req: any) => {
if (req.client.authorized && req.socket.getPeerCertificate().subject) {
return req.socket.getPeerCertificate().subject.CN;
}
return 'Unauthorized';
morgan.token('client-cn', (req: any) => {
if (req.client.authorized && req.socket.getPeerCertificate().subject) {
return req.socket.getPeerCertificate().subject.CN;
}
return 'Unauthorized';
});
}

const clientCertAuthMiddleware = (req: any, res: any, next: any) => {
if (TLS_DISABLED) {
Expand All @@ -62,7 +60,11 @@ const clientCertAuthMiddleware = (req: any, res: any, next: any) => {
};
app.use(clientCertAuthMiddleware);
app.use(bodyParser.json());
app.use(morgan(':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent" - Client-CN: :client-cn'));
if(!TLS_DISABLED) {
app.use(morgan(':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent" - Client-CN: :client-cn'));
} else {
app.use(morgan(':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent" - Client-CN: TLS Disabled'))
}

// app.use(audit());

Expand Down

0 comments on commit 317240b

Please sign in to comment.