JWT中的refresh_token
来源:互联网 发布:南风知我意许南风txt 编辑:程序博客网 时间:2024/06/07 11:12
参考链接:
https://github.com/tymondesigns/jwt-auth/issues/186
https://github.com/tymondesigns/jwt-auth/issues/11
利用JWT处理过期:
1.在普通路径下请求时如果token过期,则客户端再次发出一个请求给服务器到一个设定的refresh路径
2.在该路径下采用middleware = ‘jwt.refresh’,然后在处理函数中:
$token = JWTAuth::getToken();$newToken = JWTAuth::refresh($token);
经过尝试,以上方法是不行的!!!不能在middleware=’jwt.refresh’下,请求到的新token首先提示不存在,然后又提示进入blacklist了。解决方法是,直接起一个新的路由,然后把上面的代码放到controller的函数中。
这块没弄明白:
// fired when the token could not be found in the requestEvent::listen('tymon.jwt.absent');// fired when the token has expiredEvent::listen('tymon.jwt.expired');// fired when the token is found to be invalidEvent::listen('tymon.jwt.invalid');// fired if the user could not be found (shouldn't really happen)Event::listen('tymon.jwt.user_not_found');// fired when the token is valid (User is passed along with event)Event::listen('tymon.jwt.valid');
https://github.com/tymondesigns/jwt-auth/issues/61
这里面提到了:Add Event::listen(‘tymon.jwt.valid’) hook in the boot function of the EventServiceProvider.php, like this.
public function boot(DispatcherContract $events) { parent::boot($events); Event::listen('tymon.jwt.valid', function($event) { Auth::setUser($event); }); }
以及这段加全局异常处理,也没太明白:
Add the following code to the render method within app/Exceptions/Handler.php
public function render($request, Exception $e){ if ($e instanceof Tymon\JWTAuth\Exceptions\TokenExpiredException) { return response()->json(['token_expired'], $e->getStatusCode()); } else if ($e instanceof Tymon\JWTAuth\Exceptions\TokenInvalidException) { return response()->json(['token_invalid'], $e->getStatusCode()); } return parent::render($request, $e);}
留待思考
0 0
- JWT中的refresh_token
- JWT中的一些错误
- JWT在Retrofit中的实践
- jwt
- jwt
- JWT
- JWT
- JWT
- JWT
- JWT
- jwt
- JWT学习(二):JWT在分布式SSO中的应用实例
- 阿里开放平台获取refresh_token
- jwt(json-web-token)在rest中的实现--jersey
- jwt(json-web-token)在rest中的实现–jersey
- 微服务架构中的身份验证问题 :JSON Web Tokens( JWT)
- JWT(JSON Web Tokens)在Spring 微服务中的应用
- 使用OpenIddict,页面刷新之后refresh_token消失
- vb延时
- 17款可视化工具,让你的数据更酷炫
- 1
- 抢购逻辑的实现
- 哈弗曼树讲解---c语言实现
- JWT中的refresh_token
- 认识Java的8种基础类型
- 国家网信办发言人就“快播”案发表谈话:所有网站都应对传播内容承担法律责任
- iOS开发实践之多线程(NSOperation)
- COM 组件设计与应用(七)——编译、注册、调用
- openfire + asmack
- C---高低字节转换、printf本质、有无符号的极大极小值、_Bool
- 事件拦截
- 重拾编程之路--jeetcode(java)--Remove Duplicates from Sorted List