两种方式自定制基于JWT的认证类BaseAuthentication和BaseJSONWebTokenAuthentication方法

发布时间 2023-04-02 15:56:35作者: 与太阳肩并肩

1.基于BaseAuthentication的自定义方法

 

 

2.views中调用自定义方法MyJwtAuthentication验证

 

 

3.基于BaseAuthentication的自定义方法测试:token过期

 

 

4.基于BaseAuthentication的自定义方法测试:token数据有错误,需检查token正确性

 

 

5.基于BaseAuthentication的自定义方法测试:获取成功,并从token中打印用户信息

 

 

6.第二种基于BaseJSONWebTokenAuthentication写自定义方法(推荐使用,封装度高)