mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-22 07:53:34 +01:00
fix/generate code auth header validation (#2490)
* geenrate code for request to include collection auth headers only if request auth is of type inherit * validations
This commit is contained in:
parent
1e2b07dead
commit
929d2b5299
@ -1,12 +1,12 @@
|
||||
import get from 'lodash/get';
|
||||
|
||||
export const getAuthHeaders = (collectionRootAuth, requestAuth) => {
|
||||
const auth = collectionRootAuth && ['inherit', 'none'].includes(requestAuth.mode) ? collectionRootAuth : requestAuth;
|
||||
const auth = collectionRootAuth && ['inherit'].includes(requestAuth?.mode) ? collectionRootAuth : requestAuth;
|
||||
|
||||
switch (auth.mode) {
|
||||
case 'basic':
|
||||
const username = get(auth, 'basic.username');
|
||||
const password = get(auth, 'basic.password');
|
||||
const username = get(auth, 'basic.username', '');
|
||||
const password = get(auth, 'basic.password', '');
|
||||
const basicToken = Buffer.from(`${username}:${password}`).toString('base64');
|
||||
|
||||
return [
|
||||
@ -21,7 +21,7 @@ export const getAuthHeaders = (collectionRootAuth, requestAuth) => {
|
||||
{
|
||||
enabled: true,
|
||||
name: 'Authorization',
|
||||
value: `Bearer ${get(auth, 'bearer.token')}`
|
||||
value: `Bearer ${get(auth, 'bearer.token', '')}`
|
||||
}
|
||||
];
|
||||
default:
|
||||
|
@ -162,7 +162,7 @@ const prepareRequest = (request, collectionRoot, collectionPath) => {
|
||||
method: request.method,
|
||||
url,
|
||||
headers,
|
||||
pathParams: request.params.filter((param) => param.type === 'path'),
|
||||
pathParams: request?.params?.filter((param) => param.type === 'path'),
|
||||
responseType: 'arraybuffer'
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user