forked from usebruno/bruno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved Feat/wsse auth (usebruno#3172)
* adding wsse auth logic * adding wsse auth logic to electron * adding wsse auth formatting * Refactoring WSSE 'secret' to 'password' * Incorporating PR feedback * Removed unused packages from package.json * Fixed issue caused when resolving merge conflicts and added new route to test wsse * Removed deprecated package usages from bruno-cli * Fixed tests --------- Co-authored-by: dwolter-emarsys <dylan.wolter@emarsys.com>
- Loading branch information
1 parent
bebb18f
commit 4d820af
Showing
26 changed files
with
447 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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/CollectionSettings/Auth/WsseAuth/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; |
71 changes: 71 additions & 0 deletions
71
packages/bruno-app/src/components/CollectionSettings/Auth/WsseAuth/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,71 @@ | ||
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 { updateCollectionAuth } from 'providers/ReduxStore/slices/collections'; | ||
import { saveCollectionRoot } from 'providers/ReduxStore/slices/collections/actions'; | ||
import StyledWrapper from './StyledWrapper'; | ||
|
||
const WsseAuth = ({ collection }) => { | ||
const dispatch = useDispatch(); | ||
const { storedTheme } = useTheme(); | ||
|
||
const wsseAuth = get(collection, 'root.request.auth.wsse', {}); | ||
|
||
const handleSave = () => dispatch(saveCollectionRoot(collection.uid)); | ||
|
||
const handleUserChange = (username) => { | ||
dispatch( | ||
updateCollectionAuth({ | ||
mode: 'wsse', | ||
collectionUid: collection.uid, | ||
content: { | ||
username, | ||
password: wsseAuth.password | ||
} | ||
}) | ||
); | ||
}; | ||
|
||
const handlePasswordChange = (password) => { | ||
dispatch( | ||
updateCollectionAuth({ | ||
mode: 'wsse', | ||
collectionUid: collection.uid, | ||
content: { | ||
username: wsseAuth.username, | ||
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={wsseAuth.username || ''} | ||
theme={storedTheme} | ||
onSave={handleSave} | ||
onChange={(val) => handleUserChange(val)} | ||
collection={collection} | ||
/> | ||
</div> | ||
|
||
<label className="block font-medium mb-2">Password</label> | ||
<div className="single-line-editor-wrapper"> | ||
<SingleLineEditor | ||
value={wsseAuth.password || ''} | ||
theme={storedTheme} | ||
onSave={handleSave} | ||
onChange={(val) => handlePasswordChange(val)} | ||
collection={collection} | ||
/> | ||
</div> | ||
</StyledWrapper> | ||
); | ||
}; | ||
|
||
export default WsseAuth; |
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
17 changes: 17 additions & 0 deletions
17
packages/bruno-app/src/components/RequestPane/Auth/WsseAuth/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,17 @@ | ||
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; |
76 changes: 76 additions & 0 deletions
76
packages/bruno-app/src/components/RequestPane/Auth/WsseAuth/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,76 @@ | ||
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 WsseAuth = ({ item, collection }) => { | ||
const dispatch = useDispatch(); | ||
const { storedTheme } = useTheme(); | ||
|
||
const wsseAuth = item.draft ? get(item, 'draft.request.auth.wsse', {}) : get(item, 'request.auth.wsse', {}); | ||
|
||
const handleRun = () => dispatch(sendRequest(item, collection.uid)); | ||
const handleSave = () => dispatch(saveRequest(item.uid, collection.uid)); | ||
|
||
const handleUserChange = (username) => { | ||
dispatch( | ||
updateAuth({ | ||
mode: 'wsse', | ||
collectionUid: collection.uid, | ||
itemUid: item.uid, | ||
content: { | ||
username, | ||
password: wsseAuth.password | ||
} | ||
}) | ||
); | ||
}; | ||
|
||
const handlePasswordChange = (password) => { | ||
dispatch( | ||
updateAuth({ | ||
mode: 'wsse', | ||
collectionUid: collection.uid, | ||
itemUid: item.uid, | ||
content: { | ||
username: wsseAuth.username, | ||
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={wsseAuth.username || ''} | ||
theme={storedTheme} | ||
onSave={handleSave} | ||
onChange={(val) => handleUserChange(val)} | ||
onRun={handleRun} | ||
collection={collection} | ||
/> | ||
</div> | ||
|
||
<label className="block font-medium mb-2">Password</label> | ||
<div className="single-line-editor-wrapper"> | ||
<SingleLineEditor | ||
value={wsseAuth.password || ''} | ||
theme={storedTheme} | ||
onSave={handleSave} | ||
onChange={(val) => handlePasswordChange(val)} | ||
onRun={handleRun} | ||
collection={collection} | ||
/> | ||
</div> | ||
</StyledWrapper> | ||
); | ||
}; | ||
|
||
export default WsseAuth; |
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
Oops, something went wrong.