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 2023/01/05 07:14:48 UTC

[GitHub] [apisix] githubxubin opened a new issue, #8613: {"message":"failed to verify jwt"}

githubxubin opened a new issue, #8613:
URL: https://github.com/apache/apisix/issues/8613

   ### Description
   
   jwt-auth plugins use:
   http://url?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjM1NTIyMTk4NTQsImtleSI6Imp3dF9rZXkifQ.Tr9OvZG_ZadNCWoMqkisQ0u5DagqyArZykl6AgDUnlA
   
   the token is true but response is {"message":"failed to verify jwt"}.
   version:
   apache/apisix:2.15.0-alpine
   apache/apisix-dashboard:2.13-alpine
   bitnami/etcd:3.4.15 
   
   jwt config:
   {
     "username": "consumer_jwt",
     "desc": "consumer_jwt",
     "plugins": {
       "jwt-auth": {
         "exp": 1879318541,
         "key": "jwt_key"
       }
     }
   }
   
   ### Environment
   
   - APISIX version (run `apisix version`):
   - Operating system (run `uname -a`):
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
   - etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `luarocks --version`):
   


-- 
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.apache.org

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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "mscb402 (via GitHub)" <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439635883

   And don't have a refreshing token. When expiration has approached you can re-generate one.
   By the way, `exp` is not a timestamp. When you set `exp` to 60, It will expire in 60s after the token was generated.


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "mscb402 (via GitHub)" <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439579098

   I'm using 3.1.0. But you can try this step on your 2.15 version. I think the version will not affect it.


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "mscb402 (via GitHub)" <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439573178

   Here is my step:
   
   Step 1 : 
   Create a consumer, keep in mind `key` is very important, only this key could identify which consumer is matched.
   ```
   {
     "username": "consumer_jwt",
     "desc": "jwt_key",
     "plugins": {
       "jwt-auth": {
         "exp": 86400,
         "key": "jwt_key",
         "secret":"my_secret"
       }
     }
   }
   ```
   
   Step 2: Create 2 route
   The first one is the public API route
   ```
   {
     "uri": "/gen",
     "name": "gen",
     "plugins": {
       "public-api": {
         "uri": "/apisix/plugin/jwt/sign"
       }
     },
     "status": 1
   }
   ```
   The second is the normal route, I use the route which you provide before
   ```
   {
     "uri": "/admin/*",
     "name": "xubin_rount_admin",
     "methods": [
       "GET",
       "POST",
       "PUT",
       "DELETE",
       "PATCH",
       "HEAD",
       "OPTIONS",
       "CONNECT",
       "TRACE"
     ],
     "plugins": {
       "jwt-auth": {},
       "proxy-rewrite": {
         "regex_uri": [
           "^/admin(/|$)(.*)",
           "/$2"
         ]
       }
     },
     "upstream": {
       "nodes": [
         {
           "host": "httpbin.org",
           "port": 80,
           "weight": 1
         }
       ],
       "retries": 2,
       "timeout": {
         "connect": 6,
         "send": 6,
         "read": 6
       },
       "type": "roundrobin",
       "scheme": "http",
       "pass_host": "pass",
       "keepalive_pool": {
         "idle_timeout": 60,
         "requests": 1000,
         "size": 320
       },
       "retry_timeout": 3
     },
     "labels": {
       "API_VERSION": "v1.0"
     },
     "status": 1
   }
   ```
   
   Step 3: 
   Generate a new JWT token using public api
   ```
   curl 'http://127.0.0.1:9080/gen?key=jwt_key'
   ```
   Remember `jwt_key` should match the key you are config in the consumer. If the wrong key is set, you will get a 404 error.
   
   Step 4: Access route
   ```
   curl 'http://127.0.0.1:32541/admin/get' -H 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJqd3QiLCJleHAiOjE2NzcxMzgxMzF9.tbL6NY9xkFdEIJkAvnc0rfPMKaGgzd9Wj_TPb5aK04Q'  -i
   ```
   
   You will get this return, everything work correctly.
   ```
   HTTP/1.1 200 OK
   Content-Type: application/json
   Content-Length: 455
   Connection: keep-alive
   Date: Wed, 22 Feb 2023 07:53:32 GMT
   Access-Control-Allow-Origin: *
   Access-Control-Allow-Credentials: true
   Server: APISIX/3.1.0
   
   {
     "args": {}, 
     "headers": {
       "Accept": "*/*", 
       "Authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJqd3Rfa2V5IiwiZXhwIjoxNjc3MTM4NzkyfQ.IkNmF282LTte31niYaqYy5rlq2bHqQHiFn-yOkceJoc", 
       "Host": "127.0.0.1", 
       "User-Agent": "curl/7.84.0", 
       "X-Amzn-Trace-Id": "Root=1-63f5c9fc-57288b172fab075e2e5a202d", 
       "X-Forwarded-Host": "127.0.0.1"
     }, 
     "origin": "192.168.65.4, 61.241.66.251", 
     "url": "http://127.0.0.1/get"
   }
   ```


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1371869966

   > Hey @githubxubin, please provide your **complete steps** with APISIX version :) It's helpful to reproduce your case.
   
   and the consumer and rounte are set truely!
   1.consumer config:
   {
     "username": "consumer_jwt",
     "desc": "consumer_jwt",
     "plugins": {
       "jwt-auth": {
         "exp": 1879318541,
         "key": "jwt_key"
       }
     }
   }
   2.rounte config:
   {
     "uri": "/admin/*",
     "name": "xubin_rount_admin",
     "methods": [
       "GET",
       "POST",
       "PUT",
       "DELETE",
       "PATCH",
       "HEAD",
       "OPTIONS",
       "CONNECT",
       "TRACE"
     ],
     "plugins": {
       "jwt-auth": {
         "disable": false
       },
       "proxy-rewrite": {
         "regex_uri": [
           "^/admin(/|$)(.*)",
           "/$2"
         ]
       },
       "public-api": {
         "disable": false
       }
     },
     "upstream": {
       "nodes": [
         {
           "host": "192.168.85.66",
           "port": 8082,
           "weight": 1
         }
       ],
       "retries": 2,
       "timeout": {
         "connect": 6,
         "send": 6,
         "read": 6
       },
       "type": "roundrobin",
       "scheme": "http",
       "pass_host": "pass",
       "keepalive_pool": {
         "idle_timeout": 60,
         "requests": 1000,
         "size": 320
       },
       "retry_timeout": 3
     },
     "labels": {
       "API_VERSION": "v1.0"
     },
     "status": 1
   }


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "githubxubin (via GitHub)" <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439590088

   > I'm using 3.1.0. But you can try this step on your 2.15 version. I think the version will not affect it.
   
   the same request , the first i success but the second it is fail..55555


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


[GitHub] [apisix] githubxubin closed issue #8613: {"message":"failed to verify jwt"}

Posted by "githubxubin (via GitHub)" <gi...@apache.org>.
githubxubin closed issue #8613: {"message":"failed to verify jwt"}
URL: https://github.com/apache/apisix/issues/8613


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "githubxubin (via GitHub)" <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439460315

   > Does this help you solve this problem? 
   
   excuse me,The problem still exists!!!!  i only set the key!
   [root@localhost example]# curl http://127.0.0.1:9080/test1/ -H 'Authorization:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJqd3Rfa2V5IiwiZXhwIjoxNjc3MTMwNjM2fQ.HW-_czVK-ECTu9JPUYDbTGYYGNJjSZczoIiW1_Glvag' -i
   HTTP/1.1 401 Unauthorized
   Date: Wed, 22 Feb 2023 05:37:59 GMT
   Content-Type: text/plain; charset=utf-8
   Transfer-Encoding: chunked
   Connection: keep-alive
   Server: APISIX/2.15.0
   
   {"message":"failed to verify jwt"}
   
   
   


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "mscb402 (via GitHub)" <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439564392

   I try in my local env. You should try to set a secret in the consumer. Like this
   ```
   {
     "username": "consumer_jwt",
     "desc": "jwt_key",
     "plugins": {
       "jwt-auth": {
         "exp": 86400,
         "key": "jwt_key",
         "secret":"my_secret"
       }
     }
   }
   ```
   
   


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "githubxubin (via GitHub)" <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439588914

   > I'm using 3.1.0. But you can try this step on your 2.15 version. I think the version will not affect it.
   thank you replay ,i success but i think the function is unstable:you  can see:
   [root@localhost example]# curl 'http://127.0.0.1:9080/admin/get' -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJrZXkiOiJqd3Rfa2V5IiwiZXhwIjoxNjc3MTQwNDIwfQ.7KneQwNtch4B8JjFTZlr4fDvUOBPxLRNo9PSlG8WXe0'  -i
   HTTP/1.1 200 OK
   Content-Type: application/json
   Content-Length: 454
   Connection: keep-alive
   Date: Wed, 22 Feb 2023 08:09:30 GMT
   Access-Control-Allow-Origin: *
   Access-Control-Allow-Credentials: true
   Server: APISIX/2.15.0
   
   {
     "args": {}, 
     "headers": {
       "Accept": "*/*", 
       "Authorization": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJrZXkiOiJqd3Rfa2V5IiwiZXhwIjoxNjc3MTQwNDIwfQ.7KneQwNtch4B8JjFTZlr4fDvUOBPxLRNo9PSlG8WXe0", 
       "Host": "127.0.0.1", 
       "User-Agent": "curl/7.29.0", 
       "X-Amzn-Trace-Id": "Root=1-63f5cdba-369cdf142acd566b2a302a21", 
       "X-Forwarded-Host": "127.0.0.1"
     }, 
     "origin": "172.18.0.1, 219.141.226.82", 
     "url": "http://127.0.0.1/get"
   }
   [root@localhost example]# curl 'http://127.0.0.1:9080/admin/get' -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJrZXkiOiJqd3Rfa2V5IiwiZXhwIjoxNjc3MTQwNDIwfQ.7KneQwNtch4B8JjFTZlr4fDvUOBPxLRNo9PSlG8WXe0'  -i
   HTTP/1.1 401 Unauthorized
   Date: Wed, 22 Feb 2023 08:20:56 GMT
   Content-Type: text/plain; charset=utf-8
   Transfer-Encoding: chunked
   Connection: keep-alive
   Server: APISIX/2.15.0
   
   {"message":"failed to verify jwt"}
   


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "githubxubin (via GitHub)" <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439604129

   > if you set secret on jwt, it should be work.
   Thank you for your patient recovery, Wish you a happy life. 
   thanks again!
   
    


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "mscb402 (via GitHub)" <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439631667

   You can set the expiration time of a token, by setting `exp`


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1371909276

   Do you mean you are using key `jwt_key` and access `/apisix/plugin/jwt/sign?key=jwt_key` is not working?


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


[GitHub] [apisix] juzhiyuan commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1371862634

   Hey @githubxubin, please provide your **complete steps** with APISIX version :) It's helpful to reproduce your case.


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1376616648

   Does this help you solve this problem?


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1371903436

   > Mabey you can try access public API using `/apisix/plugin/jwt/sign?key=user-key` ?
   
   I try access public API using /apisix/plugin/jwt/sign?key=user-key. "user-key"  is ok . but the key which I set  why cannot work?


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1371913370

   > Do you mean you are using key `jwt_key` and access `/apisix/plugin/jwt/sign?key=jwt_key` is not working?
   
   the "/apisix/plugin/jwt/sign?key=jwt_key" can get the token .,but access my interface is return {"message":"failed to verify jwt"}


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1371867020

   > Hey @githubxubin, please provide your **complete steps** with APISIX version :) It's helpful to reproduce your case.
   
   1.set the public-api:
   {
     "uri": "/apisix/plugin/jwt/sign",
     "name": "",
     "plugins": {
       "public-api": {}
     },
     "status": 1
   }
   2.get the token by:/apisix/plugin/jwt/sign
   i get the token :eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjM1NTIyMTk4NTQsImtleSI6Imp3dF9rZXkifQ.Tr9OvZG_ZadNCWoMqkisQ0u5DagqyArZykl6AgDUnlA
   3.i try to request my interface with the token :
   http://url?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjM1NTIyMTk4NTQsImtleSI6Imp3dF9rZXkifQ.Tr9OvZG_ZadNCWoMqkisQ0u5DagqyArZykl6AgDUnlA
   
   return: {"message":"failed to verify jwt"}
   
   
   What went wrong?


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1371911217

   > Do you mean you are using key `jwt_key` and access `/apisix/plugin/jwt/sign?key=jwt_key` is not working?
   
   yes!  I replaced the key with user-key so it could work !!!


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


[GitHub] [apisix] githubxubin closed issue #8613: {"message":"failed to verify jwt"}

Posted by "githubxubin (via GitHub)" <gi...@apache.org>.
githubxubin closed issue #8613: {"message":"failed to verify jwt"}
URL: https://github.com/apache/apisix/issues/8613


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "githubxubin (via GitHub)" <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439621508

   > Yeah, I'm confused too. Mabey this is a document wrong or a bug. I will check it out later.
   > 
   > > > Are you set secret?
   > > 
   > > 
   > > i have known , i do not set the secret,the requst can success sametimes, but it is fail High probability, and i set the secret ,it can work truly. Doesn't this official document say that secert is not necessary???
   
   I would like to ask you a  other question, can you set the login expiration time of apisix? Or whether the token refreshing mechanism exists,help me please! thanks


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "mscb402 (via GitHub)" <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439591051

   Show you failed message for us
   
   > > I'm using 3.1.0. But you can try this step on your 2.15 version. I think the version will not affect it.
   > 
   > the same request , the first i success but the second it is fail..55555
   
   


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "mscb402 (via GitHub)" <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439590290

   Are you set secret? 


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "mscb402 (via GitHub)" <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439602491

   Yeah, I'm confused too. Mabey this is a document wrong or a bug. I will check it out later.
   
   > > Are you set secret?
   > 
   > i have known , i do not set the secret,the requst can success sametimes, but it is fail High probability, and i set the secret ,it can work truly. Doesn't this official document say that secert is not necessary???
   
   


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1371884580

   > > Hey @githubxubin, please provide your **complete steps** with APISIX version :) It's helpful to reproduce your case.
   > 
   > 1.set the public-api:
   > 
   > ```json
   > {
   >   "uri": "/apisix/plugin/jwt/sign",
   >   "name": "",
   >   "plugins": {
   >     "public-api": {}
   >   },
   >   "status": 1
   > }
   > ```
   > 
   > 2.get the token by:/apisix/plugin/jwt/sign i get the token :eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjM1NTIyMTk4NTQsImtleSI6Imp3dF9rZXkifQ.Tr9OvZG_ZadNCWoMqkisQ0u5DagqyArZykl6AgDUnlA 
   > 
   > 3.i try to request my interface with the token : 
   > http://url?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjM1NTIyMTk4NTQsImtleSI6Imp3dF9rZXkifQ.Tr9OvZG_ZadNCWoMqkisQ0u5DagqyArZykl6AgDUnlA
   > 
   > return:
   > 
   > ```json
   > {"message":"failed to verify jwt"}
   > ```
   > 
   > What went wrong?
   
   You can't set jwt in request like this way.
   You should set jwt token in header `Authorization:`, like this 
   
   ```
   curl http://127.0.0.1:9080/index.html -H 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJ1c2VyLWtleSIsImV4cCI6MTU2NDA1MDgxMX0.Us8zh_4VjJXF-TmR5f8cif8mBU7SuefPlpxhH0jbPVI' -i
   ```
   There is document you can read https://apisix.apache.org/docs/apisix/plugins/jwt-auth/


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1371891938

   > `curl http://127.0.0.1:9080/index.html -H 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJ1c2VyLWtleSIsImV4cCI6MTU2NDA1MDgxMX0.Us8zh_4VjJXF-TmR5f8cif8mBU7SuefPlpxhH0jbPVI' -i`
   
   thank you for your reply! but i get the same result with the  'Authorization': 
   `[root@localhost example]# curl http://10.20.80.105:9080/admin/syspermission/platformmanager/get/getAdminPossessMenuTree -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjM1NTIyMjI4MjQsImtleSI6Imp3dF9rZXkifQ.5no6jX1glgWQB4ujmKg96xAu75NKgHEY6ytZYMmzlnQ' -i
   HTTP/1.1 401 Unauthorized
   Date: Thu, 05 Jan 2023 07:38:20 GMT
   Content-Type: text/plain; charset=utf-8
   Transfer-Encoding: chunked
   Connection: keep-alive
   Server: APISIX/2.15.0
   
   {"message":"failed to verify jwt"}
   `


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1371891877

   Mabey you can try access public API using `/apisix/plugin/jwt/sign?key=user-key` ?


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1371998374

   Can you try this consumer config
   ```
   {
       "username": "consumer_jwt",
       "plugins": {
           "jwt-auth": {
               "key": "jwt_key",
               "secret": "this_is_secret"
           }
       }
   }
   ```


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "githubxubin (via GitHub)" <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439576577

   > Here is my step:
   > 
   > Step 1 : Create a consumer, keep in mind `key` is very important, only this key could identify which consumer is matched.
   > 
   > ```json
   > {
   >   "username": "consumer_jwt",
   >   "desc": "jwt_key",
   >   "plugins": {
   >     "jwt-auth": {
   >       "exp": 86400,
   >       "key": "jwt_key",
   >       "secret":"my_secret"
   >     }
   >   }
   > }
   > ```
   > 
   > Step 2: Create 2 route The first one is the public API route
   > 
   > ```json
   > {
   >   "uri": "/gen",
   >   "name": "gen",
   >   "plugins": {
   >     "public-api": {
   >       "uri": "/apisix/plugin/jwt/sign"
   >     }
   >   },
   >   "status": 1
   > }
   > ```
   > 
   > The second is the normal route, I use the route which you provide before
   > 
   > ```json
   > {
   >   "uri": "/admin/*",
   >   "name": "xubin_rount_admin",
   >   "methods": [
   >     "GET",
   >     "POST",
   >     "PUT",
   >     "DELETE",
   >     "PATCH",
   >     "HEAD",
   >     "OPTIONS",
   >     "CONNECT",
   >     "TRACE"
   >   ],
   >   "plugins": {
   >     "jwt-auth": {},
   >     "proxy-rewrite": {
   >       "regex_uri": [
   >         "^/admin(/|$)(.*)",
   >         "/$2"
   >       ]
   >     }
   >   },
   >   "upstream": {
   >     "nodes": [
   >       {
   >         "host": "httpbin.org",
   >         "port": 80,
   >         "weight": 1
   >       }
   >     ],
   >     "retries": 2,
   >     "timeout": {
   >       "connect": 6,
   >       "send": 6,
   >       "read": 6
   >     },
   >     "type": "roundrobin",
   >     "scheme": "http",
   >     "pass_host": "pass",
   >     "keepalive_pool": {
   >       "idle_timeout": 60,
   >       "requests": 1000,
   >       "size": 320
   >     },
   >     "retry_timeout": 3
   >   },
   >   "labels": {
   >     "API_VERSION": "v1.0"
   >   },
   >   "status": 1
   > }
   > ```
   > 
   > Step 3: Generate a new JWT token using public api
   > 
   > ```
   > curl 'http://127.0.0.1:9080/gen?key=jwt_key'
   > ```
   > 
   > Remember `jwt_key` should match the key you are config in the consumer. If the wrong key is set, you will get a 404 error.
   > 
   > Step 4: Access route
   > 
   > ```
   > curl 'http://127.0.0.1:32541/admin/get' -H 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJqd3QiLCJleHAiOjE2NzcxMzgxMzF9.tbL6NY9xkFdEIJkAvnc0rfPMKaGgzd9Wj_TPb5aK04Q'  -i
   > ```
   > 
   > You will get this return, everything work correctly.
   > 
   > ```
   > HTTP/1.1 200 OK
   > Content-Type: application/json
   > Content-Length: 455
   > Connection: keep-alive
   > Date: Wed, 22 Feb 2023 07:53:32 GMT
   > Access-Control-Allow-Origin: *
   > Access-Control-Allow-Credentials: true
   > Server: APISIX/3.1.0
   > 
   > {
   >   "args": {}, 
   >   "headers": {
   >     "Accept": "*/*", 
   >     "Authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJqd3Rfa2V5IiwiZXhwIjoxNjc3MTM4NzkyfQ.IkNmF282LTte31niYaqYy5rlq2bHqQHiFn-yOkceJoc", 
   >     "Host": "127.0.0.1", 
   >     "User-Agent": "curl/7.84.0", 
   >     "X-Amzn-Trace-Id": "Root=1-63f5c9fc-57288b172fab075e2e5a202d", 
   >     "X-Forwarded-Host": "127.0.0.1"
   >   }, 
   >   "origin": "192.168.65.4, 61.241.66.251", 
   >   "url": "http://127.0.0.1/get"
   > }
   > ```
   
   your apisix version is 2.15? my apisix version is 2.15-alpine etcd is 3.4.15


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "githubxubin (via GitHub)" <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439596668

   > Are you set secret?
   
   i have known , i do not set the secret,the requst can success sametimes, but it is fail High probability,  and i set the secret ,it can work truly.  Doesn't this official document say that secert is not necessary???
   
   


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


[GitHub] [apisix] mscb402 commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "mscb402 (via GitHub)" <gi...@apache.org>.
mscb402 commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439593499

   if you set secret on jwt, it should be work.


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


[GitHub] [apisix] githubxubin commented on issue #8613: {"message":"failed to verify jwt"}

Posted by "githubxubin (via GitHub)" <gi...@apache.org>.
githubxubin commented on issue #8613:
URL: https://github.com/apache/apisix/issues/8613#issuecomment-1439632576

   > 
   
   ok!


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