diff --git a/packages/bruno-app/src/components/RequestPane/Auth/AuthMode/index.js b/packages/bruno-app/src/components/RequestPane/Auth/AuthMode/index.js index 35cf3a47d..fe13e31f0 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/AuthMode/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/AuthMode/index.js @@ -38,7 +38,7 @@ const AuthMode = ({ item, collection }) => {
{ - dropdownTippyRef.current.hide(); + dropdownTippyRef?.current?.hide(); onModeChange('awsv4'); }} > @@ -47,7 +47,7 @@ const AuthMode = ({ item, collection }) => {
{ - dropdownTippyRef.current.hide(); + dropdownTippyRef?.current?.hide(); onModeChange('basic'); }} > @@ -56,7 +56,7 @@ const AuthMode = ({ item, collection }) => {
{ - dropdownTippyRef.current.hide(); + dropdownTippyRef?.current?.hide(); onModeChange('bearer'); }} > @@ -65,7 +65,7 @@ const AuthMode = ({ item, collection }) => {
{ - dropdownTippyRef.current.hide(); + dropdownTippyRef?.current?.hide(); onModeChange('digest'); }} > @@ -74,7 +74,16 @@ const AuthMode = ({ item, collection }) => {
{ - dropdownTippyRef.current.hide(); + dropdownTippyRef?.current?.hide(); + onModeChange('inherit'); + }} + > + Inherit +
+
{ + dropdownTippyRef?.current?.hide(); onModeChange('oauth2'); }} > @@ -83,7 +92,7 @@ const AuthMode = ({ item, collection }) => {
{ - dropdownTippyRef.current.hide(); + dropdownTippyRef?.current?.hide(); onModeChange('none'); }} > diff --git a/packages/bruno-app/src/components/RequestPane/Auth/StyledWrapper.js b/packages/bruno-app/src/components/RequestPane/Auth/StyledWrapper.js index e49220854..e1283ea42 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/StyledWrapper.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/StyledWrapper.js @@ -1,5 +1,11 @@ import styled from 'styled-components'; -const Wrapper = styled.div``; +const Wrapper = styled.div` + .inherit-mode-text { + color: ${(props) => props.theme.colors.text.yellow}; + } + .inherit-mode-label { + } +`; export default Wrapper; diff --git a/packages/bruno-app/src/components/RequestPane/Auth/index.js b/packages/bruno-app/src/components/RequestPane/Auth/index.js index 04cc954f3..730facf69 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/index.js @@ -6,11 +6,15 @@ import BearerAuth from './BearerAuth'; import BasicAuth from './BasicAuth'; import DigestAuth from './DigestAuth'; import StyledWrapper from './StyledWrapper'; +import { humanizeRequestAuthMode } from 'utils/collections/index'; import OAuth2 from './OAuth2/index'; const Auth = ({ item, collection }) => { const authMode = item.draft ? get(item, 'draft.request.auth.mode') : get(item, 'request.auth.mode'); + const collectionRoot = get(collection, 'root', {}); + const collectionAuth = get(collectionRoot, 'request.auth'); + const getAuthView = () => { switch (authMode) { case 'awsv4': { @@ -28,7 +32,14 @@ const Auth = ({ item, collection }) => { case 'oauth2': { return ; } - } + case 'inherit': { + return ( +
+
Auth inherited from the Collection:
+
{humanizeRequestAuthMode(collectionAuth?.mode)}
+
+ ); + } }; return ( diff --git a/packages/bruno-app/src/utils/collections/index.js b/packages/bruno-app/src/utils/collections/index.js index c18dbe7ce..a77a789d4 100644 --- a/packages/bruno-app/src/utils/collections/index.js +++ b/packages/bruno-app/src/utils/collections/index.js @@ -489,6 +489,10 @@ export const humanizeRequestBodyMode = (mode) => { export const humanizeRequestAuthMode = (mode) => { let label = 'No Auth'; switch (mode) { + case 'inherit': { + label = 'Inherit'; + break; + } case 'awsv4': { label = 'AWS Sig V4'; break; diff --git a/packages/bruno-cli/src/runner/prepare-request.js b/packages/bruno-cli/src/runner/prepare-request.js index 2aa16fd79..c2e5b13f7 100644 --- a/packages/bruno-cli/src/runner/prepare-request.js +++ b/packages/bruno-cli/src/runner/prepare-request.js @@ -36,7 +36,7 @@ const prepareRequest = (request, collectionRoot) => { // But it cannot override the collection auth with no auth // We will provide support for disabling the auth via scripting in the future const collectionAuth = get(collectionRoot, 'request.auth'); - if (collectionAuth) { + if (collectionAuth && request.auth.mode == 'inherit') { if (collectionAuth.mode === 'basic') { axiosRequest.auth = { username: get(collectionAuth, 'basic.username'), diff --git a/packages/bruno-electron/src/ipc/network/prepare-request.js b/packages/bruno-electron/src/ipc/network/prepare-request.js index f7317b59b..c1ec520a9 100644 --- a/packages/bruno-electron/src/ipc/network/prepare-request.js +++ b/packages/bruno-electron/src/ipc/network/prepare-request.js @@ -35,7 +35,7 @@ const parseFormData = (datas, collectionPath) => { // We will provide support for disabling the auth via scripting in the future const setAuthHeaders = (axiosRequest, request, collectionRoot) => { const collectionAuth = get(collectionRoot, 'request.auth'); - if (collectionAuth) { + if (collectionAuth && request.auth.mode == 'inherit') { switch (collectionAuth.mode) { case 'awsv4': axiosRequest.awsv4config = { diff --git a/packages/bruno-schema/src/collections/index.js b/packages/bruno-schema/src/collections/index.js index 3640a47bd..36ddf2811 100644 --- a/packages/bruno-schema/src/collections/index.js +++ b/packages/bruno-schema/src/collections/index.js @@ -168,7 +168,7 @@ const oauth2Schema = Yup.object({ .strict(); const authSchema = Yup.object({ - mode: Yup.string().oneOf(['none', 'awsv4', 'basic', 'bearer', 'digest', 'oauth2']).required('mode is required'), + mode: Yup.string().oneOf(['inherit', 'none', 'awsv4', 'basic', 'bearer', 'digest', 'oauth2']).required('mode is required'), awsv4: authAwsV4Schema.nullable(), basic: authBasicSchema.nullable(), bearer: authBearerSchema.nullable(), diff --git a/packages/bruno-tests/collection/auth/inherit auth/inherit Bearer Auth 200.bru b/packages/bruno-tests/collection/auth/inherit auth/inherit Bearer Auth 200.bru new file mode 100644 index 000000000..50cd99018 --- /dev/null +++ b/packages/bruno-tests/collection/auth/inherit auth/inherit Bearer Auth 200.bru @@ -0,0 +1,20 @@ +meta { + name: inherit Bearer Auth 200 + type: http + seq: 2 +} + +get { + url: {{host}}/api/auth/bearer/protected + body: none + auth: inherit +} + +assert { + res.status: 200 + res.body.message: Authentication successful +} + +script:post-response { + bru.setEnvVar("foo", "bar"); +} diff --git a/packages/bruno-tests/collection/collection.bru b/packages/bruno-tests/collection/collection.bru index e31b64995..dfcac9859 100644 --- a/packages/bruno-tests/collection/collection.bru +++ b/packages/bruno-tests/collection/collection.bru @@ -3,7 +3,7 @@ headers { } auth { - mode: none + mode: bearer } auth:basic { @@ -12,7 +12,7 @@ auth:basic { } auth:bearer { - token: {{bearerAuthToken}} + token: {{bearer_auth_token}} } docs {