关于使用 jwt-auth 作为 App 接口的验证请教

使用场景:用来做APP接口的验证,我们APP的接口有主账户、子账户、这些账户是拆分了不同的表,想用用JWT-AUTH,那就必须涉及到改造现有的JWT-AUT的验证及颁发。只有请求登录用户的信息时才会使用TOKEN来进行验证,公共的资源计划是使用APPID+secret+请求数据签名验证,不知道这个涉及是否安全,原来的APP接口请求?

达到目的:公共资源APPID + secret+请求数据签名验证,用户属性资源,通过获取TOKEN后,APPID + secret+TOKEN+请求数据签名验证

现在的疑惑:JWT-AUTH如果实现目前的需求貌似不太合适,使用passport貌似也不太适合需求,是自己使用开源的JWT程序来封装好些,还是使用oauth的这种方式自己来封装好些

  • 运行环境:win10+apache+php7.2
  • laravel:5.8
  • jwt_auth:1.0.0-rc.4.1

我改造了默认的使用User的表及模型,有些问题目前还没很好的解决。请求登录授权的时候都会抛一下异常,我恢复使用user模型和表依旧还是抛一样的错误

"message": "Argument 2 passed to Illuminate\\Auth\\SessionGuard::__construct() must be an instance of Illuminate\\Contracts\\Auth\\UserProvider, null given, called in E:\\Works\\develop\\dev\\f.dev.com\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php on line 125",
    "debug": {
        "line": 97,
        "file": "E:\\Works\\develop\\dev\\f.dev.com\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\SessionGuard.php",
        "class": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError",
        "trace": [
            "#0 E:\\Works\\develop\\dev\\f.dev.com\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(125): Illuminate\\Auth\\SessionGuard->__construct('web', NULL, Object(Illuminate\\Session\\Store))",
            "#1 E:\\Works\\develop\\dev\\f.dev.com\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(94): Illuminate\\Auth\\AuthManager->createSessionDriver('web', Array)",
            "#2 E:\\Works\\develop\\dev\\f.dev.com\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(68): Illuminate\\Auth\\AuthManager->resolve('web')",
            "#3 E:\\Works\\develop\\dev\\f.dev.com\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(54): Illuminate\\Auth\\AuthManager->guard('web')",
            "#4 [internal function]: Illuminate\\Auth\\AuthManager->Illuminate\\Auth\\{closure}(NULL)",
            "#5 E:\\Works\\develop\\dev\\f.dev.com\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthServiceProvider.php(84): call_user_func(Object(Closure), NULL)",
            "#6 [internal function]: Illuminate\\Auth\\AuthServiceProvider->Illuminate\\Auth\\{closure}(NULL)",
            "#7 E:\\Works\\develop\\dev\\f.dev.com\\vendor\\laravel\\framework\\src\\Illuminate\\Http\\Request.php(519): call_user_func(Object(Closure), NULL)",
            "#8 E:\\Works\\develop\\dev\\f.dev.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\ThrottleRequests.php(96): Illuminate\\Http\\Request->user()",
            "#9 E:\\Works\\develop\\dev\\f.dev.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\ThrottleRequests.php(48): Illuminate\\Routing\\Middleware\\ThrottleRequests->resolveRequestSignature(Object(Dingo\\Api\\Http\\Request))",
            "#10 E:\\Works\\develop\\dev\\f.dev.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(163): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure), '60', '1')",
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
最佳答案

博客:JWT 完整使用详解
给你一个教程,好好看看,很简单的。

4年前 评论
讨论数量: 3

博客:JWT 完整使用详解
给你一个教程,好好看看,很简单的。

4年前 评论

@jackven 看了教程就好了吗?

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!