Skip to content
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

Add backend OAuth proxy configs #841

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading