Skip to content

Commit eca67cd

Browse files
committed
Add logging to web-server
1 parent f50baac commit eca67cd

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

services/web-server/src/login/strategies/mozilla-auth0.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,28 @@ module.exports = class MozillaAuth0 {
6363
const userProfile = await personApi.getProfileFromUserId(userId);
6464
const user = new User();
6565

66-
if (!userProfile || !userProfile.user_id) {
66+
if (!userProfile) {
67+
this.monitor.debug('User profile not found', {
68+
userId,
69+
identityProviderId: 'mozilla-auth0',
70+
});
71+
72+
return;
73+
}
74+
75+
if (!userProfile.user_id) {
76+
this.monitor.debug('Profile user_id ; rejecting', {
77+
userId,
78+
identityProviderId: 'mozilla-auth0',
79+
});
80+
6781
return;
6882
}
6983

7084
if ('active' in userProfile && !userProfile.active) {
7185
this.monitor.debug('User is not active; rejecting', {
7286
userId: userProfile.user_id,
87+
identityProviderId: 'mozilla-auth0',
7388
});
7489

7590
return;

services/web-server/src/servers/oauth2.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ module.exports = (cfg, AuthorizationCode, AccessToken, strategies, auth, monitor
110110

111111
const currentUser = await strategies[user.identityProviderId].userFromIdentity(user.identity);
112112

113+
if (!currentUser) {
114+
throw new oauth2orize.AuthorizationError(null, 'server_error');
115+
}
116+
113117
const userScopes = (await auth.expandScopes({scopes: currentUser.scopes()})).scopes;
114118

115119
await AuthorizationCode.create({
@@ -317,6 +321,10 @@ module.exports = (cfg, AuthorizationCode, AccessToken, strategies, auth, monitor
317321
const { clientId, ...data } = entry.clientDetails;
318322
const currentUser = await strategies[entry.identityProviderId].userFromIdentity(entry.identity);
319323

324+
if (!currentUser) {
325+
throw inputError;
326+
}
327+
320328
// Create permacreds to give admins the ability to audit and revoke
321329
// the access at any time and that the client scanner process will
322330
// automatically disable any clients that have too many scopes

0 commit comments

Comments
 (0)