Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用过滤黑白名单unless #30

Closed
chengnuo opened this issue Aug 22, 2018 · 3 comments
Closed

使用过滤黑白名单unless #30

chengnuo opened this issue Aug 22, 2018 · 3 comments

Comments

@chengnuo
Copy link

看了源码并没有这个方法。

koa 实现

// 过滤不用jwt验证
app.use(jwt({secret: secret.sign}).unless({
    path: [
        /^\/api\/v1\/user/,
        /^\/api\/v1\/user\/login/]
}))

eggjs

ctx.app.jwt({secret: ctx.app.config.jwt.secret}).unless({
      path: [
        /^\/api\/v1\/user/,
        /^\/api\/v1\/user\/login/,
        /^\/signIn/,
      ]
      //数组中的路径不需要通过jwt验证
    })
@okoala
Copy link
Owner

okoala commented Aug 23, 2018

这种全局配置 ignore 就可以了吧

@chengnuo
Copy link
Author

在egg router 没有找到ignore那个。临时解决方案,是每个需要的接口都写上中间件。

const authToken = app.middleware.auth();

@okoala
Copy link
Owner

okoala commented Aug 23, 2018

@okoala okoala closed this as completed Aug 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants