replace debug() with our custom logger
mostly we want trace() and log(). trace() can be enabled whenever we want by flipping a flag and restarting box
This commit is contained in:
@@ -3,7 +3,7 @@ import assert from 'node:assert';
|
||||
import blobs from './blobs.js';
|
||||
import constants from './constants.js';
|
||||
import dashboard from './dashboard.js';
|
||||
import debugModule from 'debug';
|
||||
import logger from './logger.js';
|
||||
import ejs from 'ejs';
|
||||
import express from 'express';
|
||||
import fs from 'node:fs';
|
||||
@@ -21,7 +21,7 @@ import settings from './settings.js';
|
||||
import users from './users.js';
|
||||
import util from 'node:util';
|
||||
|
||||
const debug = debugModule('box:proxyAuth');
|
||||
const { log, trace } = logger('proxyAuth');
|
||||
|
||||
// heavily inspired from https://gock.net/blog/2020/nginx-subrequest-authentication-server/ and https://github.com/andygock/auth-server
|
||||
|
||||
@@ -36,7 +36,7 @@ function jwtVerify(req, res, next) {
|
||||
|
||||
jwt.verify(token, gTokenSecret, function (error, decoded) {
|
||||
if (error) {
|
||||
debug('jwtVerify: malformed token or bad signature', error.message);
|
||||
log('jwtVerify: malformed token or bad signature', error.message);
|
||||
req.user = null;
|
||||
} else {
|
||||
req.user = decoded.user || null;
|
||||
@@ -160,7 +160,7 @@ async function login(req, res, next) {
|
||||
async function callback(req, res, next) {
|
||||
if (typeof req.query.code !== 'string') return next(new HttpError(400, 'missing query argument "code"'));
|
||||
|
||||
debug(`callback: with code ${req.query.code}`);
|
||||
log(`callback: with code ${req.query.code}`);
|
||||
|
||||
const username = await oidcServer.consumeAuthCode(req.query.code);
|
||||
if (!username) return next(new HttpError(400, 'invalid "code"'));
|
||||
@@ -237,7 +237,7 @@ async function start() {
|
||||
|
||||
gTokenSecret = await blobs.getString(blobs.PROXY_AUTH_TOKEN_SECRET);
|
||||
if (!gTokenSecret) {
|
||||
debug('start: generating new token secret');
|
||||
log('start: generating new token secret');
|
||||
gTokenSecret = hat(64);
|
||||
await blobs.setString(blobs.PROXY_AUTH_TOKEN_SECRET, gTokenSecret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user