Skip to content

Commit

Permalink
chore(#1667): graceful handling of none type for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
helloanoop committed Feb 26, 2024
1 parent 7c416a9 commit 1cf8a2f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
4 changes: 3 additions & 1 deletion packages/bruno-app/src/components/RequestPane/Auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ const Auth = ({ item, collection }) => {
}
case 'inherit': {
return (
<div className="flex flex-row w-full mt-2 gap-4">
<div className="flex flex-row w-full mt-2 gap-2">
<div>Auth inherited from the Collection: </div>
<div className="inherit-mode-text">{humanizeRequestAuthMode(collectionAuth?.mode)}</div>
</div>
);
}
}
};

return (
Expand All @@ -51,4 +52,5 @@ const Auth = ({ item, collection }) => {
</StyledWrapper>
);
};

export default Auth;
17 changes: 12 additions & 5 deletions packages/bruno-cli/src/runner/prepare-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,19 @@ const prepareRequest = (request, collectionRoot) => {
headers: headers
};

// Authentication
// A request can override the collection auth with another auth
// But it cannot override the collection auth with no auth
// We will provide support for disabling the auth via scripting in the future
/**
* 27 Feb 2024:
* ['inherit', 'none'].includes(request.auth.mode)
* We are mainitaining the old behavior where 'none' used to inherit the collection auth.
*
* Very soon, 'none' will be treated as no auth and 'inherit' will be the only way to inherit collection auth.
* We will request users to update their collection files to use 'inherit' instead of 'none'.
* Don't want to break ongoing CI pipelines.
*
* Hoping to remove this by 1 April 2024.
*/
const collectionAuth = get(collectionRoot, 'request.auth');
if (collectionAuth && request.auth.mode == 'inherit') {
if (collectionAuth && ['inherit', 'none'].includes(request.auth.mode)) {
if (collectionAuth.mode === 'basic') {
axiosRequest.auth = {
username: get(collectionAuth, 'basic.username'),
Expand Down
17 changes: 12 additions & 5 deletions packages/bruno-electron/src/ipc/network/prepare-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@ const parseFormData = (datas, collectionPath) => {
return form;
};

// Authentication
// A request can override the collection auth with another auth
// But it cannot override the collection auth with no auth
// We will provide support for disabling the auth via scripting in the future
/**
* 27 Feb 2024:
* ['inherit', 'none'].includes(request.auth.mode)
* We are mainitaining the old behavior where 'none' used to inherit the collection auth.
*
* Very soon, 'none' will be treated as no auth and 'inherit' will be the only way to inherit collection auth.
* We will request users to update their collection files to use 'inherit' instead of 'none'.
* Don't want to break ongoing CI pipelines.
*
* Hoping to remove this by 1 April 2024.
*/
const setAuthHeaders = (axiosRequest, request, collectionRoot) => {
const collectionAuth = get(collectionRoot, 'request.auth');
if (collectionAuth && request.auth.mode == 'inherit') {
if (collectionAuth && ['inherit', 'none'].includes(request.auth.mode)) {
switch (collectionAuth.mode) {
case 'awsv4':
axiosRequest.awsv4config = {
Expand Down

0 comments on commit 1cf8a2f

Please sign in to comment.