AlinsRan commented on code in PR #972:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/972#discussion_r861490479


##########
docs/en/latest/practices/enable-authentication-and-restriction.md:
##########
@@ -0,0 +1,404 @@
+---
+title: Enable authentication and restriction
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+Consumers are used for the authentication method controlled by Apache APISIX, 
if users want to use their own auth system or 3rd party systems, use OIDC.  
+
+## Attributes
+
+### Authentication
+
+#### `keyAuth`
+
+Consumers add their key either in a header `apikey` to authenticate their 
requests.
+
+```yaml
+keyAuth:
+  value:
+    key: ${key}
+```
+
+#### `basicAuth`
+
+Consumers add their key either in a header `Authentication` to authenticate 
their requests.
+
+```yaml
+basicAuth:
+  value:
+    username: ${username}
+    password: ${password}
+```
+
+### Restriction
+
+#### `whitelist` or `blacklist`
+
+`whitelist`: Grant full access to all users specified in the provided list, 
**has the priority over `allowed_by_methods`**  
+`blacklist`: Reject connection to all users specified in the provided list, 
**has the priority over `whitelist`**
+
+```yaml
+plugins:
+- name: consumer-restriction
+  enable: true
+  config:
+    blacklist:
+    - "${consumer_name}"
+    - "${consumer_name}"
+```
+
+#### `allowed_by_methods`
+
+HTTP methods can be `methods:["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", 
"OPTIONS", "CONNECT", "TRACE", "PURGE"]`
+
+```yaml
+plugins:
+- name: consumer-restriction
+  enable: true
+  config:
+    allowed_by_methods:
+    - user: "${consumer_name}"
+      methods:
+      - "POST"
+      - "GET"
+    - user: "${consumer_name}"
+      methods:
+      - "GET"
+```
+
+## Example
+
+### Prepare env
+
+Kubernetes cluster:
+
+1. [apisix-ingress-controller](../deployments/minikube.md).
+2. httpbin.
+
+```shell
+#Now, try to deploy it to your Kubernetes cluster:
+kubectl run httpbin --image kennethreitz/httpbin --port 80
+kubectl expose pod httpbin --port 80
+```
+
+### How to enable `Authentication`
+
+The following is an example. The `keyAuth` is enabled on the specified route 
to restrict user access.  
+
+Create ApisixConsumer foo:
+
+```shell
+kubectl apply -f - <<EOF
+apiVersion: apisix.apache.org/v2beta3
+kind: ApisixConsumer
+metadata:
+  name: foo
+spec:
+  authParameter:
+    keyAuth:
+      value:
+        key: foo-key
+EOF
+```
+
+ApisixRoute:
+
+```shell
+kubectl apply -f -<<EOF

Review Comment:
   > Hi, may I know why we have `EOF` here?
   > 
   > Also, cc @navendu-pottekkat @kwanhur to help review. 😉
   
   It means that there after be anonymous files ending with EOF later.
   Here, it is mainly used to shorten the length of the article.
   



-- 
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-unsubscr...@apisix.apache.org

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

Reply via email to