mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-27 22:54:07 +00: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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user