Sfoglia il codice sorgente

Added fail throttling

parent
commit
aa68e6f5c0
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5
    0
      authlib.py

+ 5
- 0
authlib.py Vedi File

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