Skip to content

Commit 32307f5

Browse files
authored
fix(server): [nan-1037] on refresh keep the overrides (NangoHQ#2218)
## Describe your changes When refreshing the override goes away. Keep it around. Also adds in activity logs for an override. ## Issue ticket number and link NAN-1037 ## Checklist before requesting a review (skip if just adding/editing APIs & templates) - [ ] I added tests, otherwise the reason is: - [ ] I added observability, otherwise the reason is: - [ ] I added analytics, otherwise the reason is:
1 parent 4bfbdff commit 32307f5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

packages/server/lib/controllers/oauth.controller.ts

+21
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,27 @@ class OAuthController {
260260
oauth_client_secret_override: config.oauth_client_secret
261261
};
262262
}
263+
264+
const obfuscatedClientSecret = config.oauth_client_secret ? config.oauth_client_secret.slice(0, 4) + '***' : '';
265+
266+
await createActivityLogMessage({
267+
level: 'info',
268+
environment_id: environmentId,
269+
activity_log_id: activityLogId as number,
270+
content: 'Credentials override',
271+
timestamp: Date.now(),
272+
auth_mode: template.auth_mode,
273+
url: callbackUrl,
274+
params: {
275+
oauth_client_id: config.oauth_client_id,
276+
oauth_client_secret: obfuscatedClientSecret
277+
}
278+
});
279+
280+
await logCtx.info('Credentials override', {
281+
oauth_client_id: config.oauth_client_id,
282+
oauth_client_secret: obfuscatedClientSecret
283+
});
263284
}
264285

265286
if (connectionConfig['oauth_scopes_override']) {

packages/shared/lib/clients/oauth2.client.ts

+7
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ export async function getFreshOAuth2Credentials(
121121
newCredentials.refresh_token = credentials.refresh_token;
122122
}
123123

124+
if (credentials.config_override && credentials.config_override.client_id && credentials.config_override.client_secret) {
125+
newCredentials.config_override = {
126+
client_id: credentials.config_override.client_id,
127+
client_secret: credentials.config_override.client_secret
128+
};
129+
}
130+
124131
return { success: true, error: null, response: newCredentials };
125132
} catch (err) {
126133
const error = new NangoError(`refresh_token_parsing_error`, { cause: err });

0 commit comments

Comments
 (0)