Browse Source

Added fail throttling

Jose R Ortiz Ubarri 4 years ago
parent
commit
aa68e6f5c0
1 changed files with 5 additions and 0 deletions
  1. 5
    0
      authlib.py

+ 5
- 0
authlib.py View File

12
         self.session = session
12
         self.session = session
13
         self.id = None
13
         self.id = None
14
         self.email = None
14
         self.email = None
15
+        self.session["fc"] = 0
15
         self.fernet = Fernet(b'3UH3USxvBcFITpnVa2gvTUIMO5jbc8jqU_Q1O6SNBLs=')
16
         self.fernet = Fernet(b'3UH3USxvBcFITpnVa2gvTUIMO5jbc8jqU_Q1O6SNBLs=')
16
 
17
 
17
         if session.get("id"):
18
         if session.get("id"):
59
             print(result)
60
             print(result)
60
             self.setAuth(result["id"], result["email"])
61
             self.setAuth(result["id"], result["email"])
61
             # Añadir feature de last login.
62
             # Añadir feature de last login.
63
+            self.session["fc"] = 0
62
             return True
64
             return True
63
 
65
 
66
+        #introduce an authentication fail delay
67
+        time.sleep(self.session["fc"] * 2)
68
+        self.session["fc"] += 1
64
         return False
69
         return False
65
 
70
 
66
     def checkRole(self, tipo):
71
     def checkRole(self, tipo):