Code Monkey home page Code Monkey logo

Comments (9)

phper666 avatar phper666 commented on August 30, 2024

@flywish 你使用了哪个中间件呢?具体你可以看看Phper666\JWTAuth\Middleware\JWTAuthDefaultSceneMiddleware的逻辑,理应当前路由被匹配到后,会直接handle下个中间件了,不会进行任何jwt token校验的处理了

from jwt-auth.

phper666 avatar phper666 commented on August 30, 2024

如何使用这个no_check_route,实际配置文件里面有注释,具体可以看看注释

from jwt-auth.

phper666 avatar phper666 commented on August 30, 2024

no_check_route的路径也支持正则的方式

from jwt-auth.

flywish avatar flywish commented on August 30, 2024

from jwt-auth.

phper666 avatar phper666 commented on August 30, 2024

有什么报错吗?能否上传下你的demo我拉取测试下?

from jwt-auth.

phper666 avatar phper666 commented on August 30, 2024

我大概知道了,user/logout不能跳过token的校验,jwt的logout是必须要token才行,因为会把这个token加入到黑名单中

from jwt-auth.

flywish avatar flywish commented on August 30, 2024

环境

  • hyperf:v2.2
  • jwt-auth:v4.0

具体代码

  1. 配置全局no_check_route, 在 config/autoland/jwt.php 中设置 'no_check_route' => [ ["**", "/user/login"], ],
    image
  2. 使用全局中间件,使用 JWTAuthDefaultSceneMiddleware, 在 config/autoload/middlewares.php 中 设置 'http' => [ Hyperf\Validation\Middleware\ValidationMiddleware::class, Phper666\JWTAuth\Middleware\JWTAuthDefaultSceneMiddleware::class ]
    image
  3. 添加 /user/login 路由,添加对应控制器和方法
    image
  4. 请求接口, 发现 no_check-route 中的设置并未生效,/user/login 接口仍是400 ,提示 "Missing token"
    image

from jwt-auth.

phper666 avatar phper666 commented on August 30, 2024

@flywish 中间件的问题,更新到v4.0.3可以解决这个问题,或者使用其它提供的中间件

from jwt-auth.

flywish avatar flywish commented on August 30, 2024

OK, 看到你的解决方案了,和我预想的差不多。

from jwt-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.