Repository navigation
feat(auth): akamai auth integration #8199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3d61906
feat: add akamai edgegrid auth UI
3254980
add edgegrid siging, schema, formats
7376339
feat: support edgegrid postman migration
0e513d6
tests: add edgegrid auth unit tests
395bfc8
tests: add edgegrid auth e2e tests
92e3953
fix: resolve conflicts
bde0d74
beta: added beta flag
bf05eee
test: unit test for test_localhost
711988c
Merge branch 'main' into fix/akamaiauth-ui
sid-bruno a612d44
fix: resolved comments
ad6f0ce
Merge branch 'main' into fix/akamaiauth-ui
shubh-bruno 4352adb
Merge branch 'main' into fix/akamaiauth-ui
sid-bruno 2ff272d
Merge branch 'main' into fix/akamaiauth-ui
shubh-bruno 8db8a04
Merge branch 'main' into fix/akamaiauth-ui
sid-bruno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
97 changes: 97 additions & 0 deletions
97
packages/bruno-app/src/components/CollectionSettings/Auth/EdgeGridAuth/StyledWrapper.js
This file contains hidden or 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,97 @@ | ||
| import styled from 'styled-components'; | ||
| import { rgba } from 'polished'; | ||
|
|
||
| const StyledWrapper = styled.div` | ||
| label { | ||
| display: flex; | ||
| align-items: center; | ||
| font-size: ${(props) => props.theme.font.size.sm}; | ||
| font-weight: 500; | ||
| color: ${(props) => props.theme.colors.text.subtext1}; | ||
| margin-bottom: 0.5rem; | ||
| } | ||
|
|
||
| .single-line-editor-wrapper { | ||
| display: flex; | ||
| align-items: center; | ||
| max-width: 400px; | ||
| margin-bottom: 0.5rem; | ||
| padding: 0.15rem 0.4rem; | ||
| border-radius: 3px; | ||
| border: solid 1px ${(props) => props.theme.input.border}; | ||
| background-color: ${(props) => props.theme.input.bg}; | ||
|
|
||
| &:focus-within { | ||
| border: solid 1px ${(props) => props.theme.input.focusBorder} !important; | ||
| } | ||
| } | ||
|
|
||
| .advanced-settings-header { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 10px; | ||
| width: fit-content; | ||
| margin: 1rem 0 0.75rem; | ||
| font-size: ${(props) => props.theme.font.size.sm}; | ||
| font-weight: 600; | ||
| color: ${(props) => props.theme.colors.text.subtext1}; | ||
| user-select: none; | ||
|
|
||
| .advanced-settings-icon { | ||
| display: inline-flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| padding: 0.375rem 0.625rem; | ||
| border-radius: 0.375rem; | ||
| background-color: ${(props) => rgba(props.theme.primary.solid, 0.1)}; | ||
|
|
||
| svg { | ||
| color: ${(props) => props.theme.primary.text}; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .advanced-settings-hint { | ||
| margin: -0.25rem 0 0.75rem; | ||
| font-size: ${(props) => props.theme.font.size.sm}; | ||
| color: rgb(107 114 128); | ||
| } | ||
|
|
||
| .field-info { | ||
| position: relative; | ||
| display: inline-flex; | ||
| align-items: center; | ||
| margin-left: 6px; | ||
| cursor: pointer; | ||
|
|
||
| svg { | ||
| color: rgb(107 114 128); | ||
| } | ||
|
|
||
| .field-tooltip { | ||
| position: absolute; | ||
| left: 0; | ||
| bottom: 100%; | ||
| z-index: 10; | ||
| width: max-content; | ||
| max-width: 15rem; | ||
| margin-bottom: 0.25rem; | ||
| padding: 0.5rem; | ||
| border-radius: 0.375rem; | ||
| background-color: #374151; | ||
| color: #fff; | ||
| font-size: 0.75rem; | ||
|
sid-bruno marked this conversation as resolved.
Resolved
|
||
| line-height: 1rem; | ||
| font-weight: 400; | ||
| opacity: 0; | ||
| pointer-events: none; | ||
| transition: opacity 0.2s ease; | ||
| } | ||
|
|
||
| &:hover .field-tooltip { | ||
| opacity: 1; | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| export default StyledWrapper; | ||
165 changes: 165 additions & 0 deletions
165
packages/bruno-app/src/components/CollectionSettings/Auth/EdgeGridAuth/index.tsx
This file contains hidden or 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,165 @@ | ||
| import { IconAdjustmentsHorizontal, IconInfoCircle } from '@tabler/icons'; | ||
| import get from 'lodash/get'; | ||
| import React from 'react'; | ||
| import { useDispatch } from 'react-redux'; | ||
|
|
||
| import SensitiveFieldWarning from 'components/SensitiveFieldWarning'; | ||
| import SingleLineEditor from 'components/SingleLineEditor'; | ||
| import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField'; | ||
| import { updateCollectionAuth } from 'providers/ReduxStore/slices/collections'; | ||
| import { saveCollectionRoot } from 'providers/ReduxStore/slices/collections/actions'; | ||
| import { useTheme } from 'providers/Theme'; | ||
| import StyledWrapper from './StyledWrapper'; | ||
|
|
||
| interface AkamaiEdgeGridAuthValues { | ||
| accessToken?: string; | ||
| clientToken?: string; | ||
| clientSecret?: string; | ||
| nonce?: string; | ||
| timestamp?: string; | ||
| baseURL?: string; | ||
| headersToSign?: string; | ||
| maxBodySize?: number | null; | ||
| } | ||
|
|
||
| type EdgeGridField = keyof AkamaiEdgeGridAuthValues; | ||
|
|
||
| const toMaxBodySize = (value: string): number | null => { | ||
| if (value === '' || value == null) return null; | ||
| const num = Number(value); | ||
| return Number.isNaN(num) ? null : num; | ||
| }; | ||
|
|
||
| interface AkamaiEdgeGridAuthProps { | ||
| collection: any; | ||
| } | ||
|
|
||
| const FIELDS: Array<{ key: EdgeGridField; label: string; tooltip?: string; isSecret?: boolean }> = [ | ||
| { key: 'accessToken', label: 'Access Token' }, | ||
| { key: 'clientToken', label: 'Client Token' }, | ||
| { key: 'clientSecret', label: 'Client Secret', isSecret: true }, | ||
| { key: 'baseURL', label: 'Base URL', tooltip: 'Defaults to the request URL if not specified.' }, | ||
| { | ||
| key: 'nonce', | ||
| label: 'Nonce', | ||
| tooltip: 'A unique nonce is required per request. Defaults to an auto-generated UUID v4 if not provided.' | ||
| }, | ||
| { | ||
| key: 'timestamp', | ||
| label: 'Timestamp', | ||
| tooltip: | ||
| 'UTC timestamp of when the request is signed (yyyyMMddTHH:mm:ss+0000). Defaults to current time if not provided.' | ||
| }, | ||
| { | ||
| key: 'headersToSign', | ||
| label: 'Headers to Sign', | ||
| tooltip: 'Comma-separated list of headers to include in the signature.' | ||
| }, | ||
| { | ||
| key: 'maxBodySize', | ||
| label: 'Max Body Size', | ||
| tooltip: 'Maximum message body size to include in the signature, in bytes. Defaults to 131072.' | ||
| } | ||
| ]; | ||
|
|
||
| type EdgeGridFieldConfig = (typeof FIELDS)[number]; | ||
|
|
||
| // Fields shown up front vs. those grouped under the "Advanced Settings" section | ||
| const BASIC_FIELDS = FIELDS.slice(0, 3); | ||
| const ADVANCED_FIELDS = FIELDS.slice(3); | ||
|
|
||
| const EdgeGridAuth: React.FC<AkamaiEdgeGridAuthProps> = ({ collection }) => { | ||
| const dispatch = useDispatch(); | ||
| const { storedTheme } = useTheme(); | ||
|
|
||
| const edgeGridAuth: AkamaiEdgeGridAuthValues = | ||
| (collection.draft?.root | ||
| ? get(collection, 'draft.root.request.auth.akamaiEdgegrid') | ||
| : get(collection, 'root.request.auth.akamaiEdgegrid')) || {}; | ||
| const { isSensitive } = useDetectSensitiveField(collection); | ||
| const { showWarning: showClientSecretWarning, warningMessage: clientSecretWarningMessage } = isSensitive( | ||
| edgeGridAuth?.clientSecret | ||
| ); | ||
|
|
||
| const handleSave = () => dispatch(saveCollectionRoot(collection.uid)); | ||
|
|
||
| const handleFieldChange = (field: EdgeGridField, value: string) => { | ||
| const content: AkamaiEdgeGridAuthValues = { | ||
| accessToken: edgeGridAuth.accessToken || '', | ||
| clientToken: edgeGridAuth.clientToken || '', | ||
| clientSecret: edgeGridAuth.clientSecret || '', | ||
| nonce: edgeGridAuth.nonce || '', | ||
| timestamp: edgeGridAuth.timestamp || '', | ||
| baseURL: edgeGridAuth.baseURL || '', | ||
| headersToSign: edgeGridAuth.headersToSign || '', | ||
| maxBodySize: edgeGridAuth.maxBodySize ?? null | ||
| }; | ||
|
|
||
| if (field === 'maxBodySize') { | ||
| content.maxBodySize = toMaxBodySize(value); | ||
| } else { | ||
| (content as Record<string, unknown>)[field] = value || ''; | ||
| } | ||
|
|
||
| dispatch( | ||
| updateCollectionAuth({ | ||
| mode: 'akamai-edgegrid', | ||
| collectionUid: collection.uid, | ||
| content | ||
| }) | ||
| ); | ||
| }; | ||
|
|
||
| const renderField = ({ key, label, tooltip, isSecret }: EdgeGridFieldConfig) => { | ||
| const showWarning = isSecret && showClientSecretWarning; | ||
| const rawValue = edgeGridAuth[key]; | ||
| const fieldValue = rawValue === null || rawValue === undefined ? '' : String(rawValue); | ||
| return ( | ||
| <div key={key}> | ||
| <label> | ||
| {label} | ||
| {tooltip && ( | ||
| <span className="field-info"> | ||
| <IconInfoCircle size={16} /> | ||
| <span className="field-tooltip">{tooltip}</span> | ||
| </span> | ||
| )} | ||
| </label> | ||
| <div className="single-line-editor-wrapper"> | ||
| <SingleLineEditor | ||
| value={fieldValue} | ||
| theme={storedTheme} | ||
| onSave={handleSave} | ||
| onChange={(val: string) => handleFieldChange(key, val)} | ||
| collection={collection} | ||
| isSecret={isSecret} | ||
| isCompact | ||
| /> | ||
| {showWarning && ( | ||
| <SensitiveFieldWarning fieldName="edgegrid-client-secret" warningMessage={clientSecretWarningMessage} /> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| return ( | ||
| <StyledWrapper className="mt-2 w-full"> | ||
| {BASIC_FIELDS.map(renderField)} | ||
|
|
||
| <div className="advanced-settings-header"> | ||
| <span className="advanced-settings-icon"> | ||
| <IconAdjustmentsHorizontal size={16} /> | ||
| </span> | ||
| <span>Advanced Settings</span> | ||
| </div> | ||
|
|
||
| <> | ||
| {ADVANCED_FIELDS.map(renderField)} | ||
| </> | ||
|
|
||
| </StyledWrapper> | ||
| ); | ||
| }; | ||
|
|
||
| export default EdgeGridAuth; |
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.