Skip to content

Commit

Permalink
fix(proxy): fix proxy header construction for two_step (#3314)
Browse files Browse the repository at this point in the history
## Describe the problem and your solution
Fix Proxy header construction for `two_step` auth mode.

<!-- Issue ticket number and link (if applicable) -->

<!-- Testing instructions (skip if just adding/editing providers) -->

---------

Co-authored-by: Hassan Wari <hassanwari@Hassans-MacBook-Pro.local>
  • Loading branch information
hassan254-prog and Hassan Wari authored Jan 17, 2025
1 parent f23df04 commit 8aba672
Showing 1 changed file with 27 additions and 39 deletions.
66 changes: 27 additions & 39 deletions packages/shared/lib/services/proxy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,52 +76,39 @@ class ProxyService {
let token;
switch (connection.credentials.type) {
case 'OAUTH2':
{
const credentials = connection.credentials;
token = credentials.access_token;
}
case 'APP': {
const credentials = connection.credentials;
token = credentials.access_token;
break;
case 'OAUTH1': {
const error = new Error('OAuth1 is not supported yet in the proxy.');
const nangoError = new NangoError('pass_through_error', error);
return { success: false, error: nangoError, response: null, logs };
}
case 'BASIC':
token = connection.credentials;
break;
case 'API_KEY':
token = connection.credentials;
break;
case 'APP':
{
const credentials = connection.credentials;
token = credentials.access_token;
}
break;
case 'OAUTH2_CC':
{
const credentials = connection.credentials;
token = credentials.token;
}
break;
case 'TWO_STEP':
case 'TABLEAU':
{
const credentials = connection.credentials;
token = credentials.token;
}
break;
case 'JWT':
{
const credentials = connection.credentials;
token = credentials.token;
}
case 'SIGNATURE': {
const credentials = connection.credentials;
token = credentials.token;
break;
case 'SIGNATURE':
{
const credentials = connection.credentials;
token = credentials.token;
}
}
case 'BASIC':
case 'API_KEY':
token = connection.credentials;
break;
case 'OAUTH1': {
const error = new Error('OAuth1 is not supported yet in the proxy.');
const nangoError = new NangoError('pass_through_error', error);
return { success: false, error: nangoError, response: null, logs };
}
case 'APP_STORE':
case 'CUSTOM':
case 'TBA':
case undefined:
case 'BILL': {
break;
}
default: {
throw new Error(`Unhandled connection.credentials for: ${(connection.credentials as any).type}`);
}
}

const provider = getProvider(providerName);
Expand Down Expand Up @@ -470,6 +457,7 @@ class ProxyService {
case 'API_KEY':
case 'OAUTH2_CC':
case 'TABLEAU':
case 'TWO_STEP':
case 'JWT':
if (value.includes('connectionConfig')) {
value = value.replace(/connectionConfig\./g, '');
Expand Down

0 comments on commit 8aba672

Please sign in to comment.