moonming commented on a change in pull request #2301: URL: https://github.com/apache/apisix/pull/2301#discussion_r495425998
########## File path: doc/plugins/hmac-auth.md ########## @@ -128,7 +129,35 @@ Accept-Ranges: bytes * The signature information is separately placed in the request header: ```shell -$ curl http://127.0.0.1:9080/index.html -H 'X-HMAC-SIGNATURE: base64_encode(SIGNATURE)' -H 'X-HMAC-ALGORITHM: ALGORITHM' -H 'X-HMAC-TIMESTAMP: TIMESTAMP' -H 'X-HMAC-ACCESS-KEY: ACCESS_KEY' -H 'X-HMAC-SIGNED-HEADERS: SIGNED_HEADERS' -i +$ curl http://127.0.0.1:9080/index.html -H 'X-HMAC-SIGNATURE: base64_encode(SIGNATURE)' -H 'X-HMAC-ALGORITHM: ALGORITHM' -H 'Date: DATE' -H 'X-HMAC-ACCESS-KEY: ACCESS_KEY' -H 'X-HMAC-SIGNED-HEADERS: SIGNED_HEADERS' -i +HTTP/1.1 200 OK +Content-Type: text/html +Content-Length: 13175 +... +Accept-Ranges: bytes + +<!DOCTYPE html> +<html lang="cn"> +``` + +## Custom header key + +We can customize header key for auth parameters by adding the attribute configuration of the plugin under `plugin_attr` in `conf / config.yaml`. + +```yaml +plugin_attr: + hmac-auth: + signature_key: X-APISIX-HMAC-SIGNATURE + algorithm_key: X-APISIX-HMAC-ALGORITHM + http_date_key: X-APISIX-DATE Review comment: date_key ########## File path: doc/zh-cn/plugins/hmac-auth.md ########## @@ -130,7 +131,36 @@ Accept-Ranges: bytes * 签名信息分开分别放到请求头: ```shell -$ curl http://127.0.0.1:9080/index.html -H 'X-HMAC-SIGNATURE: base64_encode(SIGNATURE)' -H 'X-HMAC-ALGORITHM: ALGORITHM' -H 'X-HMAC-TIMESTAMP: TIMESTAMP' -H 'X-HMAC-ACCESS-KEY: ACCESS_KEY' -H 'X-HMAC-SIGNED-HEADERS: SIGNED_HEADERS' -i +$ curl http://127.0.0.1:9080/index.html -H 'X-HMAC-SIGNATURE: base64_encode(SIGNATURE)' -H 'X-HMAC-ALGORITHM: ALGORITHM' -H 'Date: DATE' -H 'X-HMAC-ACCESS-KEY: ACCESS_KEY' -H 'X-HMAC-SIGNED-HEADERS: SIGNED_HEADERS' -i +HTTP/1.1 200 OK +Content-Type: text/html +Content-Length: 13175 +... +Accept-Ranges: bytes + +<!DOCTYPE html> +<html lang="cn"> +``` + + +## 自定义 header 名称 + +我们可以在 `conf/config.yaml` 中,`plugin_attr` 下添加插件的属性配置来自定义参数 header 名称。 + +```yaml +plugin_attr: + hmac-auth: + signature_key: X-APISIX-HMAC-SIGNATURE + algorithm_key: X-APISIX-HMAC-ALGORITHM + http_date_key: X-APISIX-DATE Review comment: ditto ########## File path: doc/zh-cn/plugins/hmac-auth.md ########## @@ -130,7 +131,36 @@ Accept-Ranges: bytes * 签名信息分开分别放到请求头: ```shell -$ curl http://127.0.0.1:9080/index.html -H 'X-HMAC-SIGNATURE: base64_encode(SIGNATURE)' -H 'X-HMAC-ALGORITHM: ALGORITHM' -H 'X-HMAC-TIMESTAMP: TIMESTAMP' -H 'X-HMAC-ACCESS-KEY: ACCESS_KEY' -H 'X-HMAC-SIGNED-HEADERS: SIGNED_HEADERS' -i +$ curl http://127.0.0.1:9080/index.html -H 'X-HMAC-SIGNATURE: base64_encode(SIGNATURE)' -H 'X-HMAC-ALGORITHM: ALGORITHM' -H 'Date: DATE' -H 'X-HMAC-ACCESS-KEY: ACCESS_KEY' -H 'X-HMAC-SIGNED-HEADERS: SIGNED_HEADERS' -i +HTTP/1.1 200 OK +Content-Type: text/html +Content-Length: 13175 +... +Accept-Ranges: bytes + +<!DOCTYPE html> +<html lang="cn"> +``` + + +## 自定义 header 名称 + +我们可以在 `conf/config.yaml` 中,`plugin_attr` 下添加插件的属性配置来自定义参数 header 名称。 + +```yaml +plugin_attr: + hmac-auth: + signature_key: X-APISIX-HMAC-SIGNATURE Review comment: should use the real value ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
