Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#1003): oauth 2.0 client credentials
- Loading branch information
Anoop M D
authored and
Anoop M D
committed
Dec 17, 2023
1 parent
454e0e5
commit 5649f7c
Showing
12 changed files
with
179 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/bruno-app/src/components/RequestPane/Auth/OAuth2/StyledWrapper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import styled from 'styled-components'; | ||
|
||
const Wrapper = styled.div` | ||
label { | ||
font-size: 0.8125rem; | ||
} | ||
.single-line-editor-wrapper { | ||
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; |
78 changes: 78 additions & 0 deletions
78
packages/bruno-app/src/components/RequestPane/Auth/OAuth2/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React from 'react'; | ||
import get from 'lodash/get'; | ||
import { useTheme } from 'providers/Theme'; | ||
import { useDispatch } from 'react-redux'; | ||
import SingleLineEditor from 'components/SingleLineEditor'; | ||
import { updateAuth } from 'providers/ReduxStore/slices/collections'; | ||
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions'; | ||
import StyledWrapper from './StyledWrapper'; | ||
|
||
const OAuth2 = ({ item, collection }) => { | ||
const dispatch = useDispatch(); | ||
const { storedTheme } = useTheme(); | ||
|
||
const oAuth = item.draft ? get(item, 'draft.request.auth.oauth2', {}) : get(item, 'request.auth.oauth2', {}); | ||
|
||
const handleRun = () => dispatch(sendRequest(item, collection.uid)); | ||
const handleSave = () => dispatch(saveRequest(item.uid, collection.uid)); | ||
|
||
const handleUsernameChange = (username) => { | ||
dispatch( | ||
updateAuth({ | ||
mode: 'oauth2', | ||
collectionUid: collection.uid, | ||
itemUid: item.uid, | ||
content: { | ||
grantType: oAuth.grantType, | ||
username: username, | ||
password: oAuth.password | ||
} | ||
}) | ||
); | ||
}; | ||
|
||
const handlePasswordChange = (password) => { | ||
dispatch( | ||
updateAuth({ | ||
mode: 'oauth2', | ||
collectionUid: collection.uid, | ||
itemUid: item.uid, | ||
content: { | ||
grantType: oAuth.grantType, | ||
username: oAuth.username, | ||
password: password | ||
} | ||
}) | ||
); | ||
}; | ||
|
||
return ( | ||
<StyledWrapper className="mt-2 w-full"> | ||
<label className="block font-medium mb-2">Username</label> | ||
<div className="single-line-editor-wrapper mb-2"> | ||
<SingleLineEditor | ||
value={oAuth.username || ''} | ||
theme={storedTheme} | ||
onSave={handleSave} | ||
onChange={(val) => handleUsernameChange(val)} | ||
onRun={handleRun} | ||
collection={collection} | ||
/> | ||
</div> | ||
|
||
<label className="block font-medium mb-2">Password</label> | ||
<div className="single-line-editor-wrapper"> | ||
<SingleLineEditor | ||
value={oAuth.password || ''} | ||
theme={storedTheme} | ||
onSave={handleSave} | ||
onChange={(val) => handlePasswordChange(val)} | ||
onRun={handleRun} | ||
collection={collection} | ||
/> | ||
</div> | ||
</StyledWrapper> | ||
); | ||
}; | ||
|
||
export default OAuth2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters