From a10dde0f9a4e86654e2114b1ee74c9f2ce3e7212 Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 5 Jul 2022 16:26:37 -0400 Subject: [PATCH] moving toward production logging --- app/services/oauth2.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/services/oauth2.js b/app/services/oauth2.js index 9be9956..6b093e3 100644 --- a/app/services/oauth2.js +++ b/app/services/oauth2.js @@ -82,7 +82,7 @@ class OAuth2Service extends SiteService { const client = await OAuth2Client .findOne({ _id: clientId }) .lean(); - this.log.debug('OAuth2 client loaded', { clientId, client }); + this.log.debug('OAuth2 client loaded', { clientId }); return done(null, client); } catch (error) { this.log.error('failed to deserialize OAuth2 client', { clientId, error }); @@ -139,6 +139,7 @@ class OAuth2Service extends SiteService { }); return done(null, false); } + this.log.info('client authorization processed', { clientID }); return done(null, client, client.callbackUrl); } catch (error) { this.log.error('failed to process OAuth2 authorize', { error }); @@ -149,6 +150,7 @@ class OAuth2Service extends SiteService { async processGrant (client, redirectUri, user, ares, done) { try { var code = uuidv4(); + var ac = new OAuth2AuthorizationCode({ code, client: client._id, @@ -157,6 +159,8 @@ class OAuth2Service extends SiteService { scopes: client.scopes, }); await ac.save(); + + this.log.info('OAuth2 grant processed', { clientID: client._id, scopes: client.scopes }); return done(null, code); } catch (error) { this.log.error('failed to process OAuth2 grant', { error }); @@ -178,7 +182,6 @@ class OAuth2Service extends SiteService { }, ]); - this.log.debug('process OAuth2 exchange', { client, code, redirectUri }); if (!client._id.equals(ac.client._id)) { this.log.alert('OAuth2 client ID mismatch', { provided: client.id, onfile: ac.client._id }); return done(null, false); @@ -197,7 +200,7 @@ class OAuth2Service extends SiteService { }); await at.save(); - this.log.debug('OAuth2 grant exchanged for token', { client, code, token: at.token }); + this.log.info('OAuth2 grant exchanged for token', { clientID: client._id }); return done(null, token); } catch (error) { this.log.error('failed to process OAuth2 exchange', { error });