diff --git a/packages/bruno-app/src/components/FolderSettings/Auth/StyledWrapper.js b/packages/bruno-app/src/components/FolderSettings/Auth/StyledWrapper.js
new file mode 100644
index 000000000..ecb0976df
--- /dev/null
+++ b/packages/bruno-app/src/components/FolderSettings/Auth/StyledWrapper.js
@@ -0,0 +1,16 @@
+import styled from 'styled-components';
+
+const Wrapper = styled.div`
+ label {
+ font-size: 0.8125rem;
+ }
+ .single-line-editor-wrapper {
+ max-width: 400px;
+ padding: 0.15rem 0.4rem;
+ border-radius: 3px;
+ border: solid 1px ${(props) => props.theme.input.border};
+ background-color: ${(props) => props.theme.input.bg};
+ }
+`;
+
+export default Wrapper;
\ No newline at end of file
diff --git a/packages/bruno-app/src/components/FolderSettings/Auth/index.js b/packages/bruno-app/src/components/FolderSettings/Auth/index.js
new file mode 100644
index 000000000..4ef704cd7
--- /dev/null
+++ b/packages/bruno-app/src/components/FolderSettings/Auth/index.js
@@ -0,0 +1,86 @@
+import React from 'react';
+import get from 'lodash/get';
+import StyledWrapper from './StyledWrapper';
+import { saveFolderRoot } from 'providers/ReduxStore/slices/collections/actions';
+import OAuth2AuthorizationCode from 'components/RequestPane/Auth/OAuth2/AuthorizationCode/index';
+import { updateFolderAuth } from 'providers/ReduxStore/slices/collections';
+import { useDispatch } from 'react-redux';
+import OAuth2PasswordCredentials from 'components/RequestPane/Auth/OAuth2/PasswordCredentials/index';
+import OAuth2ClientCredentials from 'components/RequestPane/Auth/OAuth2/ClientCredentials/index';
+import GrantTypeSelector from 'components/RequestPane/Auth/OAuth2/GrantTypeSelector/index';
+import AuthMode from '../AuthMode';
+
+const grantTypeComponentMap = (collection, folder) => {
+ const dispatch = useDispatch();
+
+ const save = () => {
+ dispatch(saveFolderRoot(collection.uid, folder.uid));
+ };
+
+ let request = get(folder, 'root.request', {});
+ const grantType = get(request, 'auth.oauth2.grantType', 'authorization_code');
+
+ switch (grantType) {
+ case 'password':
+ return ;
+ case 'authorization_code':
+ return ;
+ case 'client_credentials':
+ return ;
+ default:
+ return
- {tokenPlacement == 'url' ? 'URL' : 'Headers'}
+ {tokenPlacement == 'url' ? 'URL' : 'Headers'}
);
@@ -54,7 +58,7 @@ const OAuth2AuthorizationCode = ({ save, item = {}, request, handleRun, updateAu
const CredentialsPlacementIcon = forwardRef((props, ref) => {
return (
- {credentialsPlacement == 'body' ? 'Request Body' : 'Basic Auth Header'}
+ {credentialsPlacement == 'body' ? 'Request Body' : 'Basic Auth Header'}
);
@@ -67,11 +71,16 @@ const OAuth2AuthorizationCode = ({ save, item = {}, request, handleRun, updateAu
requestCopy.headers = {};
toggleFetchingToken(true);
try {
- await dispatch(fetchOauth2Credentials({ itemUid: item.uid, request: requestCopy, collection }));
+ await dispatch(fetchOauth2Credentials({
+ itemUid: item.uid,
+ request: requestCopy,
+ collection,
+ folderUid: folder?.uid || null
+ }));
toggleFetchingToken(false);
toast.success('token fetched successfully!');
}
- catch(error) {
+ catch (error) {
console.error(error);
toggleFetchingToken(false);
toast.error('An error occured while fetching token!');
@@ -88,14 +97,14 @@ const OAuth2AuthorizationCode = ({ save, item = {}, request, handleRun, updateAu
toggleRefreshingToken(false);
toast.success('token refreshed successfully!');
}
- catch(error) {
+ catch (error) {
console.error(error);
toggleRefreshingToken(false);
toast.error('An error occured while refreshing token!');
}
}
- const handleSave = () => {save();};
+ const handleSave = () => { save(); };
const handleChange = (key, value) => {
dispatch(
@@ -118,10 +127,10 @@ const OAuth2AuthorizationCode = ({ save, item = {}, request, handleRun, updateAu
tokenPlacement,
tokenHeaderPrefix,
tokenQueryKey,
- reuseToken,
refreshUrl,
- autoRefresh,
- [key]: value
+ autoRefreshToken,
+ autoFetchToken,
+ [key]: value,
}
})
);
@@ -147,7 +156,7 @@ const OAuth2AuthorizationCode = ({ save, item = {}, request, handleRun, updateAu
tokenPlacement,
tokenHeaderPrefix,
tokenQueryKey,
- reuseToken,
+ autoFetchToken,
pkce: !Boolean(oAuth?.['pkce'])
}
})
@@ -165,10 +174,10 @@ const OAuth2AuthorizationCode = ({ save, item = {}, request, handleRun, updateAu
});
};
- const { uid: collectionUid } = collection;
- const interpolatedUrl = interpolateStringUsingCollectionAndItem({ collection, item, string: accessTokenUrl });
- const credentialsData = find(collection?.oauth2Credentials, creds => creds?.url == interpolatedUrl && creds?.collectionUid == collectionUid && creds?.credentialsId == credentialsId);
- const creds = credentialsData?.credentials || {};
+ const { uid: collectionUid } = collection;
+ const interpolatedUrl = interpolateStringUsingCollectionAndItem({ collection, item, string: accessTokenUrl });
+ const credentialsData = find(collection?.oauth2Credentials, creds => creds?.url == interpolatedUrl && creds?.collectionUid == collectionUid && creds?.credentialsId == credentialsId);
+ const creds = credentialsData?.credentials || {};
useEffect(() => {
// Update visibility whenever credentials change
@@ -302,7 +311,7 @@ const OAuth2AuthorizationCode = ({ save, item = {}, request, handleRun, updateAu
/>
- :
+ :
-
-
handleChange('autoRefresh', e.target.checked)}
- />
-
Automatically refresh the token when it expires
+
+ {/* Automatically Fetch Token */}
+
+
handleChange('autoFetchToken', e.target.checked)}
+ className="cursor-pointer ml-1"
+ />
+
+
+
+
+
+ Automatically fetch a new token when you try to access a resource and don't have one.
+
+
+
+
+
+ {/* Auto Refresh Token (With Refresh URL) */}
+
+
handleChange('autoRefreshToken', e.target.checked)}
+ className={`cursor-pointer ml-1 ${isAutoRefreshDisabled ? 'opacity-50 cursor-not-allowed' : ''}`}
+ disabled={isAutoRefreshDisabled}
+ />
+
+
+
+
+
+ Automatically refresh your token using the refresh URL when it expires.
+
+
+
+
{showRefreshButton && (
)}
+
+
+ {/* Automatically Fetch Token */}
+
+
handleChange('autoFetchToken', e.target.checked)}
+ className="cursor-pointer ml-1"
+ />
+
+
+
+
+
+ Automatically fetch a new token when you try to access a resource and don't have one.
+
+
+
+
+
+ {/* Auto Refresh Token (With Refresh URL) */}
+
+
handleChange('autoRefreshToken', e.target.checked)}
+ className={`cursor-pointer ml-1 ${isAutoRefreshDisabled ? 'opacity-50 cursor-not-allowed' : ''}`}
+ disabled={isAutoRefreshDisabled}
+ />
+
+
+
+
+
+ Automatically refresh your token using the refresh URL when it expires.
+
+
+
+
+