riskgod opened a new issue #4117:
URL: https://github.com/apache/apisix/issues/4117


   hey I add Date into the SIGNATURE, but it failed, please help a check. thank 
you. 
   ```
   curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
   {
       "username": "kelly",
       "plugins": {
           "hmac-auth": {
               "access_key": "user-key-kelly",
               "secret_key": "my-secret-key—kelly",
               "clock_skew": 5,
               "signed_headers": ["Date", "User-Agent", "x-custom-a"]
           }
       }
   }'
   ```
   
   ```
   const crypto = require('crypto');
   const axios = require('axios').default;
   const today = new Date();
   const dataNow = today.toGMTString();
   
   const live = 
   `GET
   /health
   
   user-key-kelly
   ${dataNow}
   User-Agent:curl/7.29.0
   x-custom-a:test
   `;
   
   
   const test_signature = crypto.createHmac('sha256', 
"my-secret-key—kelly").update(live).digest("base64");
   
   const headers = {
       "X-HMAC-SIGNATURE": test_signature,
       "X-HMAC-ALGORITHM": "hmac-sha256",
       "X-HMAC-ACCESS-KEY": "user-key-kelly",
       "X-HMAC-SIGNED-HEADERS": "Date;User-Agent;x-custom-a",
       "Date": dataNow,
       "User-Agent": "curl/7.29.0",
       "x-custom-a": "test"
   }
   
   const options = {
     method: 'GET',
     headers: headers,
     url:"http://127.0.0.1:9080/health";,
   };
   
   async function test() {
      try {
       const result = await axios(options);
       console.log(result)
      } catch (error) {
          console.error(error.response.data)
      } 
   }
   
   test()
   
   ```


-- 
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]


Reply via email to