Skip to content

Commit

Permalink
Merge pull request #841 from rmsamitha/main
Browse files Browse the repository at this point in the history
Add backend OAuth proxy configs
  • Loading branch information
rmsamitha authored Nov 29, 2024
2 parents 89ac020 + 295cb01 commit 76eb3c4
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 1 deletion.
5 changes: 5 additions & 0 deletions portals/publisher/src/main/webapp/site/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,11 @@
"Apis.Details.Endpoints.GeneralConfiguration.EndpointSecurity.oauth.grant.type.password": "Resource Owner Password",
"Apis.Details.Endpoints.GeneralConfiguration.EndpointSecurity.password.input": "Password",
"Apis.Details.Endpoints.GeneralConfiguration.EndpointSecurity.password.message": "Enter Password",
"Apis.Details.Endpoints.GeneralConfiguration.EndpointSecurity.proxyHost.input": "Proxy Hostname",
"Apis.Details.Endpoints.GeneralConfiguration.EndpointSecurity.proxyPassword.input": "Proxy Password",
"Apis.Details.Endpoints.GeneralConfiguration.EndpointSecurity.proxyPort.input": "Proxy Port",
"Apis.Details.Endpoints.GeneralConfiguration.EndpointSecurity.proxyProtocol.input": "Proxy Protocol",
"Apis.Details.Endpoints.GeneralConfiguration.EndpointSecurity.proxyUsername.input": "Proxy Username",
"Apis.Details.Endpoints.GeneralConfiguration.EndpointSecurity.socket.\n timeout.duration": "Socket Timeout Duration (ms)",
"Apis.Details.Endpoints.GeneralConfiguration.EndpointSecurity.token.endpoint.\n connection.configurations": "Token Endpoint Connection Configurations",
"Apis.Details.Endpoints.GeneralConfiguration.EndpointSecurity.token.url.input": "Token URL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import {
ListItem,
ListItemAvatar,
ListItemText,
Switch,
FormGroup,
FormControlLabel,
} from '@mui/material';
import { FormattedMessage, injectIntl } from 'react-intl';
import Table from '@mui/material/Table';
Expand Down Expand Up @@ -103,6 +106,17 @@ function EndpointSecurity(props) {
intl, securityInfo, onChangeEndpointAuth, isProduction, saveEndpointSecurityConfig, closeEndpointSecurityConfig,
} = props;
const [endpointSecurityInfo, setEndpointSecurityInfo] = useState(CONSTS.DEFAULT_ENDPOINT_SECURITY);

if (!(securityInfo?.proxyConfigs != null)) {
securityInfo.proxyConfigs = {
proxyEnabled: false,
proxyHost: '',
proxyPort: '',
proxyUsername: '',
proxyPassword: '',
proxyProtocol: '',
};
}
const [securityValidity, setSecurityValidity] = useState();

const [showAddParameter, setShowAddParameter] = useState(false);
Expand Down Expand Up @@ -189,7 +203,7 @@ function EndpointSecurity(props) {
tmpSecurity = { ...securityInfo };
const {
type, username, password, grantType, tokenUrl, clientId, clientSecret, customParameters,
connectionTimeoutDuration, connectionRequestTimeoutDuration, socketTimeoutDuration,
connectionTimeoutDuration, connectionRequestTimeoutDuration, socketTimeoutDuration, proxyConfigs,
} = securityInfo;
const secretPlaceholder = '******';
tmpSecurity.type = type === null ? 'NONE' : type;
Expand All @@ -203,6 +217,7 @@ function EndpointSecurity(props) {
tmpSecurity.connectionTimeoutDuration = connectionTimeoutDuration;
tmpSecurity.connectionRequestTimeoutDuration = connectionRequestTimeoutDuration;
tmpSecurity.socketTimeoutDuration = socketTimeoutDuration;
tmpSecurity.proxyConfigs = proxyConfigs;
}
setEndpointSecurityInfo(tmpSecurity);
}, [securityInfo]);
Expand Down Expand Up @@ -727,6 +742,178 @@ function EndpointSecurity(props) {
</>
)}

<Grid
item
xs={12}
style={{
paddingTop: '30px',
}}
/>
<Grid
item
xs={12}
style={{
paddingTop: '20px',
borderTop: '1px solid Gainsboro',
}}
>
<FormGroup row>
<FormControlLabel
control={(
<Switch
name='proxyEnabled'
onChange={(event) => {
endpointSecurityInfo.proxyConfigs.proxyEnabled = event.target.checked;
setEndpointSecurityInfo({ ...endpointSecurityInfo });
validateAndUpdateSecurityInfo('proxyEnabled');
}}
checked={endpointSecurityInfo.proxyConfigs.proxyEnabled}
/>
)}
label='Proxy Configurations'
/>

</FormGroup>
</Grid>
<Grid
item
xs={6}
style={{}}
>
<TextField
disabled={isRestricted(['apim:api_create'], api)
|| !endpointSecurityInfo.proxyConfigs.proxyEnabled}
required
fullWidth
variant='outlined'
id='proxy-host'
label={(
<FormattedMessage
id={'Apis.Details.Endpoints.GeneralConfiguration.'
+ 'EndpointSecurity.proxyHost.input'}
defaultMessage='Proxy Hostname'
/>
)}
onChange={(event) => {
endpointSecurityInfo.proxyConfigs.proxyHost = event.target.value;
setEndpointSecurityInfo({ ...endpointSecurityInfo });
validateAndUpdateSecurityInfo('proxyConfigs');
}}
value={endpointSecurityInfo.proxyConfigs.proxyHost}
onBlur={() => validateAndUpdateSecurityInfo('proxyConfigs')}
/>
</Grid>
<Grid
item
xs={6}
style={{}}
>
<TextField
disabled={isRestricted(['apim:api_create'], api)
|| !endpointSecurityInfo.proxyConfigs.proxyEnabled}
required
fullWidth
variant='outlined'
id='proxy-port'
label={(
<FormattedMessage
id={'Apis.Details.Endpoints.GeneralConfiguration.'
+ 'EndpointSecurity.proxyPort.input'}
defaultMessage='Proxy Port'
/>
)}
onChange={(event) => {
endpointSecurityInfo.proxyConfigs.proxyPort = event.target.value;
setEndpointSecurityInfo({ ...endpointSecurityInfo });
validateAndUpdateSecurityInfo('proxyConfigs');
}}
value={endpointSecurityInfo.proxyConfigs.proxyPort}
onBlur={() => validateAndUpdateSecurityInfo('proxyConfigs')}
/>
</Grid>
<Grid
item
xs={6}
style={{}}
>
<TextField
disabled={isRestricted(['apim:api_create'], api)
|| !endpointSecurityInfo.proxyConfigs.proxyEnabled}
fullWidth
variant='outlined'
id='proxy-username'
label={(
<FormattedMessage
id={'Apis.Details.Endpoints.GeneralConfiguration.'
+ 'EndpointSecurity.proxyUsername.input'}
defaultMessage='Proxy Username'
/>
)}
onChange={(event) => {
endpointSecurityInfo.proxyConfigs.proxyUsername = event.target.value;
setEndpointSecurityInfo({ ...endpointSecurityInfo });
validateAndUpdateSecurityInfo('proxyConfigs');
}}
value={endpointSecurityInfo.proxyConfigs.proxyUsername}
onBlur={() => validateAndUpdateSecurityInfo('proxyConfigs')}
/>
</Grid>
<Grid
item
xs={6}
style={{}}
>
<TextField
disabled={isRestricted(['apim:api_create'], api)
|| !endpointSecurityInfo.proxyConfigs.proxyEnabled}
fullWidth
variant='outlined'
id='proxy-password'
type='password'
label={(
<FormattedMessage
id={'Apis.Details.Endpoints.GeneralConfiguration.'
+ 'EndpointSecurity.proxyPassword.input'}
defaultMessage='Proxy Password'
/>
)}
onChange={(event) => {
endpointSecurityInfo.proxyConfigs.proxyPassword = event.target.value;
setEndpointSecurityInfo({ ...endpointSecurityInfo });
validateAndUpdateSecurityInfo('proxyConfigs');
}}
value={endpointSecurityInfo.proxyConfigs.proxyPassword}
onBlur={() => validateAndUpdateSecurityInfo('proxyConfigs')}
/>
</Grid>
<Grid
item
xs={6}
style={{}}
>
<TextField
disabled={isRestricted(['apim:api_create'], api)
|| !endpointSecurityInfo.proxyConfigs.proxyEnabled}
required
fullWidth
variant='outlined'
id='proxy-protocol'
label={(
<FormattedMessage
id={'Apis.Details.Endpoints.GeneralConfiguration.'
+ 'EndpointSecurity.proxyProtocol.input'}
defaultMessage='Proxy Protocol'
/>
)}
onChange={(event) => {
endpointSecurityInfo.proxyConfigs.proxyProtocol = event.target.value;
setEndpointSecurityInfo({ ...endpointSecurityInfo });
validateAndUpdateSecurityInfo('proxyConfigs');
}}
value={endpointSecurityInfo.proxyConfigs.proxyProtocol}
onBlur={() => validateAndUpdateSecurityInfo('proxyConfigs')}
/>
</Grid>
<Grid item xs={12}>
<ListItem
className={classes.listItem}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ const CONSTS = {
connectionTimeoutDuration: -1,
connectionRequestTimeoutDuration: -1,
socketTimeoutDuration: -1,
proxyConfigs: {
proxyEnabled: '',
proxyHost: '',
proxyPort: '',
proxyUsername: '',
proxyPassword: '',
proxyProtocol: '',
},
},
GATEWAY_TYPE: {
synapse: 'Synapse',
Expand Down

0 comments on commit 76eb3c4

Please sign in to comment.