当前位置:网站首页>5 login failures, limiting login practice
5 login failures, limiting login practice
2022-06-23 10:25:00 【cfcoolya】
One Restrict login practices
Design thinking
1.0 background
Recently, I have been developing the function module functions of the open management platform of liaoshitong institution .
This module involves registering 、 Sign in 、 Entry and other functions .
The technologies involved are SpringBoot、Mybatis、Spring Security、Jwt、Npm、vue-cli、vue-router、vuex、element-ui
1.1 Ideas
Back end thinking :
There are several cases of login failure :
The captcha is invalid
Verification code error
User password input error
The above three situations are progressive , The third kind of words belongs to spring security Level certification . So we need to judge how many login failures occur before the third one , If exceeded 5 Once directly limit , Unable to enter the third authentication .
1.2 How to achieve ?
Add a " User system access table " .
This table records the user account number 、 Sign in IP、 Place of entry 、 Browser type 、 Access time 、 Login status successful or failed .
Whether a user logs in to the system successfully or unsuccessfully is recorded in this table .
Before entering the third user authentication , Perform five failed verifications .
1. Using paging user name + Failed status reverse order query
2. When the query result has 5, At this time, we need to judge whether the input fails five times in a day .
long firstTime = loginList.get(4).getLoginTime().getTime();
long lastTime = loginList.get(0).getLoginTime().getTime();
long nowTime = new Date().getTime();
long limitTime = Integer.parseInt(policys[1]) * 60 * 60 * 1000;// Limit one day
if((firstTime + limitTime > lastTime) && (lastTime + limitTime > nowTime)){" Too many failures , Login has been restricted "));
throw new CustomException(" Too many failures , Login has been restricted ");}
That is to say If you find out 5 Failed login records , We have to decide whether it is the number of failures in a day .
So the earliest record + One day > The latest record , The latest record + One day > Now? , If these two conditions are true, it means the number of failures in a day .
边栏推荐
- Pet Feeder Based on stm32
- What is a good quick development framework like?
- NOI OJ 1.2 10:Hello, World!的大小 C语言
- 2021-04-15
- 2021-05-11 static keyword
- Numerical calculation method
- Lying trough, the most amazing paper artifact!
- 数值计算方法
- Nuxt.js spa与ssr的区别
- Install the typescript environment and enable vscode to automatically monitor the compiled TS file as a JS file
猜你喜欢
随机推荐
Gorm advanced query
High performance computing center Infiniband overview
Pet Feeder Based on stm32
2021-05-12 interface definition and Implementation
regular expression
NOI OJ 1.4 04:奇偶ASCII值判断 C语言
2021-04-16 array
Developer, you may have some misunderstandings about cloud computing
thymeleaf如何取url中请求参数值?
Year end answer sheet! Tencent cloud intelligent comprehensive strength ranks first in China!
文献综述怎么写 ,一直没头绪写不出来怎么办?
2021-05-10 method rewrite polymorphism considerations
2021-04-16 recursion
Set up a QQ robot for ordering songs, and watch beautiful women
2021-05-11 static keyword
用贪吃蛇小游戏表白(附源码)
2021-05-12接口的定义与实现
2021-05-07封装 继承 super this
NOI OJ 1.3 20:计算2的幂 C语言
Liujinhai, architect of zhongang Mining: lithium battery opens up a Xintiandi for fluorine chemical industry








