当前位置:网站首页>JWT token practice and problem solving
JWT token practice and problem solving
2022-04-22 20:17:00 【New ape and horse】
Catalog
One token Interface modification
3、 ... and During the class token Not overdue
Four The old version APP Don't break down
5、 ... and Password change ,token invalid
6、 ... and Issued by 、 The contract token Interface security
7、 ... and token Issue controllable
8、 ... and token Certified interface pressure test
JWT Realization token authentication Tells the story of JWT Some basic concepts , Use JWT token The advantages and disadvantages of and the problems needing attention in use . This chapter is mainly about the use of JWT token Problems encountered in the process and solutions .
One token Interface modification
token What is it? ?token It's issued when the user logs in .
Transform the scene : The Intranet has some interfaces through token To get user information , This is not reasonable .
I understand it : token It's used to authenticate users , It should be transferred between external networks ; All kinds of business should be transferred between intranet id.
Solution : Getting user information should use user_id. Now that I can get it token, explain token After the certification service , The certification service will return user_id.
Two token Valid for
We're generating access_token、refresh_token The expiration date will be set when the application is completed , hypothesis access_token Valid for 2 Hours ,refresh_token by 24 Hours . Testers can't wait while testing functions
2 Hour or 24 Hours! , So how to solve , The validity period is too long ? In order to improve the test efficiency , Make it access_token、refresh_token It's all configurable , for instance 1 Minutes expired 、5 It's OK to expire in minutes .
3、 ... and During the class token Not overdue
The company has a business scenario where students have classes , How to make sure that the students are in class token invalid 、 It won't happen ? Once occurred token invalid 、 It's easy to have a bad user experience when you log out , There are all kinds of complaints .
The root cause of this problem is during class token invalid , In this case, we just need to make sure that token It doesn't fail during class , For example, we can set token The failure time is in the early morning . The kids go to sleep in the early morning .
Four The old version APP Don't break down
In awarding JWT token When , There will be JWT token、 The old token Problems at the same time ; And JWT token There is a renewal process , The old token There is no . because APP Login is using h5 page , If it's awarded JWT token,
once JWT token Be overdue , Go through the renewal process ,APP It's easy to break down . How can we guarantee APP It doesn't collapse ? Just make sure that APP The old version is the old one token、 New version issued JWT token. So how to guarantee ? Because login is h5
page , Front end version control , The back end cooperates with the front end JWT token、 The old token, That is to say, the front end tells me to send JWT token, I'll send it out JWT token; The front end told me to send the old token, I'll give it to you token.
5、 ... and Password change ,token invalid
because JWT token It's distributed , That is to say, if you don't do anything else , Password change ,JWT token It won't work . How can I guarantee the password change ,JWT token Failure ?
The initial assumption is to put the password in JWT token Of payload Inside , This way is equivalent to exposing the password to the outside, there is a certain risk . Later I thought it was JWT token Add a password change timestamp , What does that mean ?
Let's say that the JWT token The version is v1, The user changed the password tomorrow , After login version JWT token The version is v2, be v2 Previous version v1 All of them will be invalid . such , To change the password , JWT token invalid .
6、 ... and Issued by 、 The contract token Interface security
Issued by token、 The contract token The two interfaces are sensitive interfaces , How to ensure the security of these two interfaces ? In other words, calling these two interfaces requires a white list .
Here we use the interface API Signature and verification mechanism . Only specific services can call our issuance token、 The contract token Two interfaces .
7、 ... and token Issue controllable
Because it was awarded JWT token, How to ensure that the risk is controllable ? First , We aim at token The distribution made a switch , It can be issued at any time token Function offline ;
secondly , In order to advance a little bit JWT token , We aim at mobile (userId)-> appId Do it .
8、 ... and token Certified interface pressure test
Because it is JWT token, And the pressure of certification service is very high , In order to ensure the stability of the system , This needs to be certified JWT token Interface pressure test .
版权声明
本文为[New ape and horse]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221912434626.html
边栏推荐
- C语言位域应用--一个字节存八个标志位
- Acrobat Pro DC 教程,如何使用密码保护 PDF 文件?
- Connection method of Jincang database kingbasees
- sys_ When CTL starts Kingbase stand-alone service, an error is reported: could not bind IPv4 address "0.0.0.0": address already in use
- 【建议收藏】面试没亮点
- Module 4 operation
- 第二章 数组
- Chapter 2 array
- Panyu maritime department has solidly promoted the 100 day action of safety education and training for water practitioners
- Comparison and principle summary of golang local cache selection
猜你喜欢

sys_ When CTL starts Kingbase stand-alone service, an error is reported: could not bind IPv4 address "0.0.0.0": address already in use

对话木瓜移动创始人沈思 l 从硅谷到北京

Implementation of calico official website network topology: Based on ENSP and vmvare

Don't say, "I don't like development, so I choose testing."

Write a gateway service, understand more thoroughly!

Micro diary: Those seemingly insignificant details and experiences

Selenium automatic pop-up processing

Timestamp conversion

MarkDown 学习

The WiFi next door, I break every second
随机推荐
DBUS client user guide
sys_ctl启动kingbase单机服务时报错:could not bind IPv4 address “0.0.0.0“: Address already in use
Time and date formatting
【Unity/C#】游戏出现区域性崩溃,深藏的国际化巨坑
Where should 2021 fresh graduates go?
手写一个网关服务,理解更透彻!
Filebeat
【建议收藏】面试没亮点
day29
掌握这些引用参考文献的小Tips,助您论文写作事半功倍~
Solve the problem that kingbasees cannot open the lock file
判断是否发生塑性变形的条件:von Mises屈服准则
常类型的使用 常成员函数(设计一个日期类和时间)
IAP之boot实现
"Shandong University project training" Research on radiation pre calculation rendering and post-processing noise reduction system (I)
Introduction notes to PHP zero Foundation (11): String
Cannot proceed because system tables used by Event Scheduler were found damaged
Application of C language bit field -- storing eight flag bits in one byte
STM32 uses USB virtual serial port + ymodem to upgrade IAP
day29