You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by kv...@apache.org on 2020/10/28 05:37:30 UTC

[apisix] branch master updated: fix: the plugin hmac-auth missed a `\n` (#2543)

This is an automated email from the ASF dual-hosted git repository.

kvn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 146e222  fix: the plugin hmac-auth missed a `\n` (#2543)
146e222 is described below

commit 146e222e0c821abb1c8b2bf30a3d77b373fb4dcc
Author: Firstsawyou <52...@users.noreply.github.com>
AuthorDate: Wed Oct 28 13:37:22 2020 +0800

    fix: the plugin hmac-auth missed a `\n` (#2543)
    
    * fix: the plugin hmac-auth missed a `\n`.
    fix #2527
    
    * docs: modify doc.
    
    * fix: consumer-restriction.t and custom_hmac_auth.t
---
 apisix/plugins/hmac-auth.lua    |  2 +-
 doc/plugins/hmac-auth.md        |  2 +-
 doc/zh-cn/plugins/hmac-auth.md  |  2 +-
 t/plugin/consumer-restriction.t |  8 ++++----
 t/plugin/custom_hmac_auth.t     |  2 +-
 t/plugin/hmac-auth.t            | 14 +++++++-------
 6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/apisix/plugins/hmac-auth.lua b/apisix/plugins/hmac-auth.lua
index 57160d7..6e961d3 100644
--- a/apisix/plugins/hmac-auth.lua
+++ b/apisix/plugins/hmac-auth.lua
@@ -241,7 +241,7 @@ local function generate_signature(ctx, secret_key, params)
         end
     end
 
-    local signing_string = core.table.concat(signing_string_items, "\n")
+    local signing_string = core.table.concat(signing_string_items, "\n") .. "\n"
 
     core.log.info("signing_string: ", signing_string,
                   " params.signed_headers:",
diff --git a/doc/plugins/hmac-auth.md b/doc/plugins/hmac-auth.md
index 8c1bf10..9c480b3 100644
--- a/doc/plugins/hmac-auth.md
+++ b/doc/plugins/hmac-auth.md
@@ -111,7 +111,7 @@ The calculation formula of the signature is `signature = HMAC-SHAx-HEX(secret_ke
 HeaderKey1 + ":" + HeaderValue1 + "\n"\+
 HeaderKey2 + ":" + HeaderValue2 + "\n"\+
 ...
-HeaderKeyN + ":" + HeaderValueN
+HeaderKeyN + ":" + HeaderValueN + "\n"
 ```
 
 Here is a full example:
diff --git a/doc/zh-cn/plugins/hmac-auth.md b/doc/zh-cn/plugins/hmac-auth.md
index 82a873f..2d7fbbd 100644
--- a/doc/zh-cn/plugins/hmac-auth.md
+++ b/doc/zh-cn/plugins/hmac-auth.md
@@ -111,7 +111,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
 HeaderKey1 + ":" + HeaderValue1 + "\n"\+
 HeaderKey2 + ":" + HeaderValue2 + "\n"\+
 ...
-HeaderKeyN + ":" + HeaderValueN
+HeaderKeyN + ":" + HeaderValueN + "\n"
 ```
 
 拼接后的示例:
diff --git a/t/plugin/consumer-restriction.t b/t/plugin/consumer-restriction.t
index bca9817..4d1e041 100644
--- a/t/plugin/consumer-restriction.t
+++ b/t/plugin/consumer-restriction.t
@@ -733,7 +733,7 @@ location /t {
             "x-custom-header-a:" .. custom_header_a,
             "x-custom-header-b:" .. custom_header_b
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
 
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)
         core.log.info("signature:", ngx_encode_base64(signature))
@@ -898,7 +898,7 @@ location /t {
             "x-custom-header-a:" .. custom_header_a,
             "x-custom-header-b:" .. custom_header_b
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
 
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)
         core.log.info("signature:", ngx_encode_base64(signature))
@@ -1077,7 +1077,7 @@ location /t {
             "x-custom-header-a:" .. custom_header_a,
             "x-custom-header-b:" .. custom_header_b
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
 
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)
         core.log.info("signature:", ngx_encode_base64(signature))
@@ -1197,7 +1197,7 @@ location /t {
             "x-custom-header-a:" .. custom_header_a,
             "x-custom-header-b:" .. custom_header_b
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
 
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)
         core.log.info("signature:", ngx_encode_base64(signature))
diff --git a/t/plugin/custom_hmac_auth.t b/t/plugin/custom_hmac_auth.t
index 3fc4751..249840b 100644
--- a/t/plugin/custom_hmac_auth.t
+++ b/t/plugin/custom_hmac_auth.t
@@ -254,7 +254,7 @@ location /t {
             "x-custom-header-a:" .. custom_header_a,
             "x-custom-header-b:" .. custom_header_b
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
 
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)
         core.log.info("signature:", ngx_encode_base64(signature))
diff --git a/t/plugin/hmac-auth.t b/t/plugin/hmac-auth.t
index 42ca212..22cc2a4 100644
--- a/t/plugin/hmac-auth.t
+++ b/t/plugin/hmac-auth.t
@@ -347,7 +347,7 @@ location /t {
             "x-custom-header-a:" .. custom_header_a,
             "x-custom-header-b:" .. custom_header_b
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
         core.log.info("signing_string:", signing_string)
 
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)
@@ -579,7 +579,7 @@ location /t {
             "x-custom-header-a:" .. custom_header_a,
             "x-custom-header-b:" .. custom_header_b
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
         core.log.info("signing_string:", signing_string)
 
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)
@@ -644,7 +644,7 @@ location /t {
             "x-custom-header-a:" .. custom_header_a,
             "x-custom-header-b:" .. custom_header_b
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
 
         core.log.info("signing_string:", signing_string)
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)
@@ -815,7 +815,7 @@ location /t {
             gmt,
             "x-custom-header-a:" .. custom_header_a
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
 
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)
         core.log.info("signature:", ngx_encode_base64(signature))
@@ -977,7 +977,7 @@ location /t {
             "x-custom-header-a:" .. custom_header_a,
             "x-custom-header-b:" .. custom_header_b
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
         core.log.info("signing_string:", signing_string)
 
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)
@@ -1093,7 +1093,7 @@ location /t {
             "x-custom-header-a:" .. custom_header_a,
             "x-custom-header-b:" .. custom_header_b
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
         core.log.info("signing_string:", signing_string)
 
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)
@@ -1209,7 +1209,7 @@ location /t {
             "x-custom-header-a:" .. custom_header_a,
             "x-custom-header-b:" .. custom_header_b
         }
-        signing_string = core.table.concat(signing_string, "\n")
+        signing_string = core.table.concat(signing_string, "\n") .. "\n"
         core.log.info("signing_string:", signing_string)
 
         local signature = hmac:new(secret_key, hmac.ALGOS.SHA256):final(signing_string)