mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-25 17:33:28 +01:00
Refactor auth interpolation in request utils
This commit is contained in:
parent
f49eddf7ec
commit
876c763486
@ -26,7 +26,7 @@ const interpolateRequest = (request, combinedVars) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const interpolateAuth = (auth) => {
|
const interpolateAuth = (auth) => {
|
||||||
if (auth.type === 'oauth2') {
|
if (auth.mode === 'oauth2') {
|
||||||
const { oauth2 } = auth;
|
const { oauth2 } = auth;
|
||||||
if (oauth2?.grantType) {
|
if (oauth2?.grantType) {
|
||||||
let username, password, scope, clientId, clientSecret;
|
let username, password, scope, clientId, clientSecret;
|
||||||
@ -81,17 +81,25 @@ const interpolateRequest = (request, combinedVars) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (auth.type === 'basic') {
|
} else if (auth.mode === 'basic') {
|
||||||
auth.username = interpolate(auth.username, combinedVars);
|
const { basic } = auth;
|
||||||
auth.password = interpolate(auth.password, combinedVars);
|
|
||||||
} else if (auth.type === 'bearer') {
|
basic.username = interpolate(basic.username, combinedVars);
|
||||||
auth.token = interpolate(auth.token, combinedVars);
|
basic.password = interpolate(basic.password, combinedVars);
|
||||||
} else if (auth.type === 'wsse') {
|
} else if (auth.mode === 'bearer') {
|
||||||
auth.username = interpolate(auth.username, combinedVars);
|
const { bearer } = auth;
|
||||||
auth.password = interpolate(auth.password, combinedVars);
|
|
||||||
} else if (auth.type === 'digest') {
|
bearer.token = interpolate(bearer.token, combinedVars);
|
||||||
auth.username = interpolate(auth.username, combinedVars);
|
} else if (auth.mode === 'wsse') {
|
||||||
auth.password = interpolate(auth.password, combinedVars);
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user