Skip to content

Commit

Permalink
Refactor auth interpolation in request utils
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjai0py committed Sep 26, 2024
1 parent f49eddf commit 876c763
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions packages/bruno-app/src/utils/collections/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const interpolateRequest = (request, combinedVars) => {
};

const interpolateAuth = (auth) => {
if (auth.type === 'oauth2') {
if (auth.mode === 'oauth2') {
const { oauth2 } = auth;
if (oauth2?.grantType) {
let username, password, scope, clientId, clientSecret;
Expand Down Expand Up @@ -81,17 +81,25 @@ const interpolateRequest = (request, combinedVars) => {
break;
}
}
} else if (auth.type === 'basic') {
auth.username = interpolate(auth.username, combinedVars);
auth.password = interpolate(auth.password, combinedVars);
} else if (auth.type === 'bearer') {
auth.token = interpolate(auth.token, combinedVars);
} else if (auth.type === 'wsse') {
auth.username = interpolate(auth.username, combinedVars);
auth.password = interpolate(auth.password, combinedVars);
} else if (auth.type === 'digest') {
auth.username = interpolate(auth.username, combinedVars);
auth.password = interpolate(auth.password, combinedVars);
} else if (auth.mode === 'basic') {
const { basic } = auth;

basic.username = interpolate(basic.username, combinedVars);
basic.password = interpolate(basic.password, combinedVars);
} else if (auth.mode === 'bearer') {
const { bearer } = auth;

bearer.token = interpolate(bearer.token, combinedVars);
} else if (auth.mode === 'wsse') {
const { wsse } = auth;

wsse.username = interpolate(wsse.username, combinedVars);
wsse.password = interpolate(wsse.password, combinedVars);
} else if (auth.mode === 'digest') {
const { digest } = auth;

digest.username = interpolate(digest.username, combinedVars);
digest.password = interpolate(digest.password, combinedVars);
}
};

Expand Down

0 comments on commit 876c763

Please sign in to comment.