oidcserver: convert to trace
This commit is contained in:
+14
-14
@@ -33,7 +33,7 @@ import util from 'node:util';
|
||||
import Provider from 'oidc-provider';
|
||||
import mailpasswords from './mailpasswords.js';
|
||||
|
||||
const { log } = logger('oidcserver');
|
||||
const { log, trace } = logger('oidcserver');
|
||||
|
||||
|
||||
// 1. Index.vue starts the OIDC flow by navigating to /openid/auth. Webadmin sets callback url to authcallback.html + implicit flow
|
||||
@@ -83,12 +83,12 @@ class StorageAdapter {
|
||||
}
|
||||
|
||||
constructor(name) {
|
||||
log(`Creating OpenID storage adapter for ${name}`);
|
||||
trace(`Creating OpenID storage adapter for ${name}`);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
async upsert(id, payload, expiresIn) {
|
||||
log(`[${this.name}] upsert: ${id}`);
|
||||
trace(`[${this.name}] upsert: ${id}`);
|
||||
|
||||
const expiresAt = expiresIn ? new Date(Date.now() + (expiresIn * 1000)) : 0;
|
||||
|
||||
@@ -111,7 +111,7 @@ class StorageAdapter {
|
||||
}
|
||||
|
||||
async find(id) {
|
||||
log(`[${this.name}] find: ${id}`);
|
||||
trace(`[${this.name}] find: ${id}`);
|
||||
|
||||
if (this.name === 'Client') {
|
||||
const [error, client] = await safe(oidcClients.get(id));
|
||||
@@ -184,7 +184,7 @@ class StorageAdapter {
|
||||
}
|
||||
|
||||
async findByUserCode(userCode) {
|
||||
log(`[${this.name}] findByUserCode userCode:${userCode}`);
|
||||
trace(`[${this.name}] findByUserCode userCode:${userCode}`);
|
||||
const data = await StorageAdapter.getData(this.name);
|
||||
for (const id in data) {
|
||||
if (data[id].payload.userCode === userCode) return data[id].payload;
|
||||
@@ -194,7 +194,7 @@ class StorageAdapter {
|
||||
|
||||
// this is called only on Session store. there is a payload.uid
|
||||
async findByUid(uid) {
|
||||
log(`[${this.name}] findByUid: ${uid}`);
|
||||
trace(`[${this.name}] findByUid: ${uid}`);
|
||||
|
||||
const data = await StorageAdapter.getData(this.name);
|
||||
for (const d in data) {
|
||||
@@ -205,19 +205,19 @@ class StorageAdapter {
|
||||
}
|
||||
|
||||
async consume(id) {
|
||||
log(`[${this.name}] consume: ${id}`);
|
||||
trace(`[${this.name}] consume: ${id}`);
|
||||
|
||||
await StorageAdapter.updateData(this.name, (data) => data[id].consumed = true);
|
||||
}
|
||||
|
||||
async destroy(id) {
|
||||
log(`[${this.name}] destroy: ${id}`);
|
||||
trace(`[${this.name}] destroy: ${id}`);
|
||||
|
||||
await StorageAdapter.updateData(this.name, (data) => delete data[id]);
|
||||
}
|
||||
|
||||
async revokeByGrantId(grantId) {
|
||||
log(`[${this.name}] revokeByGrantId: ${grantId}`);
|
||||
trace(`[${this.name}] revokeByGrantId: ${grantId}`);
|
||||
|
||||
await StorageAdapter.updateData(this.name, (data) => {
|
||||
for (const d in data) {
|
||||
@@ -291,7 +291,7 @@ async function renderError(error) {
|
||||
language: await settings.get(settings.LANGUAGE_KEY),
|
||||
};
|
||||
|
||||
log('renderError: %o', error);
|
||||
trace('renderError: %o', error);
|
||||
|
||||
return ejs.render(TEMPLATE_ERROR, data);
|
||||
}
|
||||
@@ -360,7 +360,7 @@ async function interactionLogin(req, res, next) {
|
||||
const ip = req.headers['x-forwarded-for'] || req.socket.remoteAddress || null;
|
||||
const clientId = details.params.client_id;
|
||||
|
||||
log(`interactionLogin: for OpenID client ${clientId} from ${ip}`);
|
||||
trace(`interactionLogin: for OpenID client ${clientId} from ${ip}`);
|
||||
|
||||
if (req.body.autoLoginToken) { // auto login for first admin/owner
|
||||
if (typeof req.body.autoLoginToken !== 'string') return next(new HttpError(400, 'autoLoginToken must be string if provided'));
|
||||
@@ -403,10 +403,10 @@ async function interactionLogin(req, res, next) {
|
||||
if (userPasskeys.length > 0) {
|
||||
const [passkeyError] = await safe(passkeys.verifyAuthentication(user, passkeyResponse));
|
||||
if (passkeyError) {
|
||||
log(`interactionLogin: passkey verification failed for ${username}: ${passkeyError.message}`);
|
||||
trace(`interactionLogin: passkey verification failed for ${username}: ${passkeyError.message}`);
|
||||
return next(new HttpError(401, 'Invalid passkey'));
|
||||
}
|
||||
log(`interactionLogin: passkey verified for ${username}`);
|
||||
trace(`interactionLogin: passkey verified for ${username}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ async function interactionConfirm(req, res, next) {
|
||||
if (detailsError) return next(new HttpError(detailsError.statusCode, detailsError.error_description));
|
||||
const { grantId, uid, prompt: { name, details }, params, session: { accountId }, lastSubmission } = interactionDetails;
|
||||
|
||||
log(`route interaction confirm post uid:${uid} prompt.name:${name} accountId:${accountId}`);
|
||||
trace(`route interaction confirm post uid:${uid} prompt.name:${name} accountId:${accountId}`);
|
||||
|
||||
const client = await oidcClients.get(params.client_id);
|
||||
if (!client) return next(new Error('Client not found'));
|
||||
|
||||
Reference in New Issue
Block a user