You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/02/11 01:48:08 UTC

[GitHub] [apisix-dashboard] guoqqqi commented on a change in pull request #2290: chore: added form function to authz-casbin plugin

guoqqqi commented on a change in pull request #2290:
URL: https://github.com/apache/apisix-dashboard/pull/2290#discussion_r804301828



##########
File path: CHANGELOG.md
##########
@@ -50,7 +50,7 @@ This release contains some features and bugfixes, and all the existing functiona
 ### Bugfix
 
 - fix: supports search by name for service options when add router [#2066](https://github.com/apache/apisix-dashboard/pull/2066)
-- fix: gzip plugin schema typo [#2142](https://github.com/apache/apisix-dashboard/pull/2142)
+- fix: gzip schema typo [#2142](https://github.com/apache/apisix-dashboard/pull/2142)

Review comment:
       What is the reason for this change?

##########
File path: web/src/components/Plugin/UI/authz-keycloak.tsx
##########
@@ -0,0 +1,92 @@
+import { FormInstance, Input } from "antd";
+import React from "react";
+import { useIntl } from "umi";
+import Form from "antd/es/form";
+
+type Props = {
+    form: FormInstance;
+    schema: Record<string, any> | undefined;
+    ref?: any;
+}
+
+const FORM_ITEM_LAYOUT = {
+    labelCol: {
+        span: 7,
+    },
+    wrapperCol: {
+        span: 8,
+    },
+};
+
+const AuthzKeycloak: React.FC<Props> = ({ form, schema }) => {
+    const { formatMessage } = useIntl();
+    const properties = schema?.properties
+
+    return (
+        <Form form={form} {...FORM_ITEM_LAYOUT}>
+            <Form.Item
+                name="token_endpoint"
+                label="token_endpoint"
+                rules={[
+                    {
+                        required: true,
+                        message: `${formatMessage({ id: 'component.global.pleaseEnter' })} token_endpoint`,
+                    },
+                ]}
+                initialValue={properties.token_endpoint.default}
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.token_endpoint.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="grant_type"
+                label="grant_type"
+                initialValue={"urn:ietf:params:oauth:grant-type:uma-ticket"}
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.grant_type.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="audience"
+                label="audience"
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.audience.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="permissions"
+                label="permissions"
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.permissions.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="timeout"
+                label="timeout"
+                initialValue={3000}
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.timeout.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="ssl_verify"
+                label="ssl_verify"
+                initialValue={"ture"}
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.ssl_verify.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="policy_enforcement_mode"
+                label="policy_enforcement_mode"
+                initialValue={"ENFORCING"}
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.policy_enforcement_mode.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+
+        </Form >
+    )
+}
+
+export default AuthzKeycloak

Review comment:
       need a new blank

##########
File path: web/src/components/Plugin/UI/plugin.tsx
##########
@@ -75,6 +79,11 @@ export const PluginForm: React.FC<Props> = ({ name, schema, renderForm, form })
       return <LimitConn form={form} schema={schema} />;
     case 'referer-restriction':
       return <RefererRestriction form={form} schema={schema} />;
+    case 'authz-casbin':
+      return <AuthzCasbin form={form} schema={schema} />;
+      case 'authz-keycloak':
+      return <AuthzKeycloak form={form} schema={schema} />;

Review comment:
       format code the file

##########
File path: web/src/components/Plugin/UI/authz-keycloak.tsx
##########
@@ -0,0 +1,92 @@
+import { FormInstance, Input } from "antd";
+import React from "react";
+import { useIntl } from "umi";
+import Form from "antd/es/form";
+
+type Props = {
+    form: FormInstance;
+    schema: Record<string, any> | undefined;
+    ref?: any;
+}
+
+const FORM_ITEM_LAYOUT = {
+    labelCol: {
+        span: 7,
+    },
+    wrapperCol: {
+        span: 8,
+    },
+};
+
+const AuthzKeycloak: React.FC<Props> = ({ form, schema }) => {
+    const { formatMessage } = useIntl();
+    const properties = schema?.properties
+
+    return (
+        <Form form={form} {...FORM_ITEM_LAYOUT}>
+            <Form.Item
+                name="token_endpoint"
+                label="token_endpoint"
+                rules={[
+                    {
+                        required: true,
+                        message: `${formatMessage({ id: 'component.global.pleaseEnter' })} token_endpoint`,
+                    },
+                ]}
+                initialValue={properties.token_endpoint.default}
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.token_endpoint.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="grant_type"
+                label="grant_type"
+                initialValue={"urn:ietf:params:oauth:grant-type:uma-ticket"}
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.grant_type.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="audience"
+                label="audience"
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.audience.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="permissions"
+                label="permissions"
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.permissions.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="timeout"
+                label="timeout"
+                initialValue={3000}
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.timeout.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="ssl_verify"
+                label="ssl_verify"
+                initialValue={"ture"}
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.ssl_verify.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="policy_enforcement_mode"
+                label="policy_enforcement_mode"
+                initialValue={"ENFORCING"}
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-keycloak.policy_enforcement_mode.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+
+        </Form >
+    )
+}
+
+export default AuthzKeycloak

Review comment:
       and format the file

##########
File path: yarn.lock
##########
@@ -0,0 +1,4 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1

Review comment:
       This file seems to be a redundant file

##########
File path: web/src/components/Plugin/UI/authz-casbin.tsx
##########
@@ -0,0 +1,76 @@
+import { useIntl } from "umi";
+import Form, { FormInstance } from "antd/es/form";
+import React from "react";
+import { Input } from "antd";
+
+type Props = {

Review comment:
       Please set spaces to 2 and format the code

##########
File path: web/src/components/Plugin/UI/authz-casbin.tsx
##########
@@ -0,0 +1,76 @@
+import { useIntl } from "umi";
+import Form, { FormInstance } from "antd/es/form";
+import React from "react";
+import { Input } from "antd";
+
+type Props = {
+    form: FormInstance;
+    schema: Record<string, any> | undefined;
+    ref?: any;
+}
+
+const FORM_ITEM_LAYOUT = {
+    labelCol: {
+        span: 7,
+    },
+    wrapperCol: {
+        span: 8,
+    },
+};
+
+const AuthzCasbin: React.FC<Props> = ({ form, schema }) => {
+    const { formatMessage } = useIntl();
+    const properties = schema?.properties
+    
+    return (
+        <Form form={form} {...FORM_ITEM_LAYOUT}>
+            <Form.Item
+                name="model_path"
+                label="model_path"
+                rules={[
+                    {
+                      required: true,
+                      message: `${formatMessage({ id: 'component.global.pleaseEnter' })} model_path`,
+                    },
+                  ]}
+                initialValue={properties.model_path.default}
+                tooltip={formatMessage({ id: 'component.pauginForm.authz-casbin.model_path.tooltip' })}
+            >
+                <Input />
+            </Form.Item>
+            <Form.Item
+                name="policy_path"
+                label="policy_path"
+                rules={[
+                    {
+                      required: true,
+                      message: `${formatMessage({ id: 'component.global.pleaseEnter' })} policy_path`,
+                    },
+                  ]}
+                initialValue={properties.policy_path.default}
+                tooltip={formatMessage({ id: 'compoenet.pauginForm.authz-casbin.policy_path.tooltip'})}
+            >
+               <Input />
+            </Form.Item>
+            
+            <Form.Item
+               name="username"
+               label="username"
+               rules={[
+                {
+                  required: true,
+                  message: `${formatMessage({ id: 'component.global.pleaseEnter' })} username`,
+                },
+              ]}
+               initialValue={properties.username.defalt}
+               tooltip={formatMessage({ id:'compoenet.pauginForm.authz-casbin.username.tooltip'})}
+            >
+              <Input/>
+            </Form.Item>
+        </Form >
+    )
+}
+
+
+
+export default AuthzCasbin

Review comment:
       Usually we need to add a new blank line at the end of the file




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org