Skip to content

Commit

Permalink
removed jwt claims template from transform and added claims in graphq…
Browse files Browse the repository at this point in the history
…l rule
  • Loading branch information
shubham4443 committed Jan 30, 2021
1 parent 4941b7b commit 1d482b2
Showing 1 changed file with 48 additions and 50 deletions.
98 changes: 48 additions & 50 deletions src/components/security-rules/configure-rule/ConfigureRule.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,19 @@ const ConfigureRule = (props) => {
delete values["applyTransformations"]
break;
case "graphql":
try {
values.graphqlVariables = JSON.parse(values.graphqlVariables);
if (values.generateToken) {
values.claims = JSON.parse(values.claims)
}
delete values["generateToken"]
} catch (ex) {
notify("error", "Error", ex.toString())
return;
}
break;
case "transform":
if (values["applyTransformations"]) {
values.template = "go"
}

delete values["applyTransformations"]
break;
}

Expand All @@ -229,7 +235,7 @@ const ConfigureRule = (props) => {
if (!props.selectedRule.clauses) values.clauses = [];
else values.clauses = props.selectedRule.clauses
}
if (values.rule === "query" || values.rule === "webhook" || values.rule === "force" || values.rule === "remove" || values.rule === "encrypt" || values.rule === "decrypt" || values.rule === "hash" || values.rule === "graphql" || values.rule === "transform") {
if (values.rule === "query" || values.rule === "webhook" || values.rule === "force" || values.rule === "remove" || values.rule === "encrypt" || values.rule === "decrypt" || values.rule === "hash" || values.rule === "transform") {
values.clause = props.selectedRule.clause
values.fields = values.loadVar ? values.singleInputFields : values.multipleInputFields
delete values["loadVar"]
Expand Down Expand Up @@ -781,6 +787,20 @@ const ConfigureRule = (props) => {
<FormItem name="store" rules={[{ required: false }]}>
<Input placeholder="The variable to store the query response. For example: args.res" />
</FormItem>
<Form.Item name='generateToken' valuePropName='checked'>
<Checkbox>
Generate token
</Checkbox>
</Form.Item>
<ConditionalFormBlock
dependency='generateToken'
condition={() => form.getFieldValue('generateToken') === true}
>
<FormItemLabel name="JWT claims" />
<Form.Item name="claims">
<JSONCodeMirror />
</Form.Item>
</ConditionalFormBlock>
</ConditionalFormBlock>
<ConditionalFormBlock
dependency="rule"
Expand All @@ -789,52 +809,30 @@ const ConfigureRule = (props) => {
<FormItem name="store" rules={[{ required: false }]}>
<Input placeholder="The variable to store the transform response. For example: args.res" />
</FormItem>
<FormItemLabel name='Apply transformations' />
<Form.Item name='applyTransformations' valuePropName='checked'>
<Checkbox>
Transform the request body using templates
</Checkbox>
<Alert
message={<AlertMsgApplyTransformations />}
type='info'
showIcon
style={{ marginBottom: 21 }}
/>
<FormItemLabel name="Template output format" description="Format for parsing the template output" />
<Form.Item name="outputFormat">
<Select style={{ width: 96 }}>
<Option value='yaml'>YAML</Option>
<Option value='json'>JSON</Option>
</Select>
</Form.Item>
<FormItemLabel name="Request template" hint="(Optional)" description="Template to generate the transformed request body" />
<Form.Item name='requestTemplate' >
<AntCodeMirror style={{ border: "1px solid #D9D9D9" }} options={{
mode: { name: 'go' },
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
autoCloseBrackets: true,
tabSize: 2
}} />
</Form.Item>
<ConditionalFormBlock
dependency='applyTransformations'
condition={() => form.getFieldValue('applyTransformations') === true}
>
<Alert
message={<AlertMsgApplyTransformations />}
type='info'
showIcon
style={{ marginBottom: 21 }}
/>
<FormItemLabel name="Template output format" description="Format for parsing the template output" />
<Form.Item name="outputFormat">
<Select style={{ width: 96 }}>
<Option value='yaml'>YAML</Option>
<Option value='json'>JSON</Option>
</Select>
</Form.Item>
<FormItemLabel name="JWT claims template" hint="(Optional)" description="Template to generate the transformed claims of the request" />
<Form.Item name="claims">
<AntCodeMirror style={{ border: "1px solid #D9D9D9" }} options={{
mode: { name: 'go' },
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
autoCloseBrackets: true,
tabSize: 2
}} />
</Form.Item>
<FormItemLabel name="Request template" hint="(Optional)" description="Template to generate the transformed request body" />
<Form.Item name='requestTemplate' >
<AntCodeMirror style={{ border: "1px solid #D9D9D9" }} options={{
mode: { name: 'go' },
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
autoCloseBrackets: true,
tabSize: 2
}} />
</Form.Item>
</ConditionalFormBlock>
</ConditionalFormBlock>
<FormItemLabel name='Customize error message' />
<Form.Item name='errorMsg' valuePropName='checked'>
Expand Down

0 comments on commit 1d482b2

Please sign in to comment.