ajouter des sécurité sur les URL, les Roles, les mdp
This commit is contained in:
+9
-2
@@ -2,7 +2,8 @@ from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_login import LoginManager
|
||||
from flask_wtf.csrf import CSRFProtect
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
|
||||
from flask_limiter import Limiter
|
||||
from flask_limiter.util import get_remote_address
|
||||
|
||||
# Database and extension initialization
|
||||
db = SQLAlchemy()
|
||||
@@ -11,6 +12,12 @@ login_manager.login_view = 'auth.login'
|
||||
login_manager.login_message_category = 'info'
|
||||
csrf = CSRFProtect()
|
||||
|
||||
# Rate limiter for brute-force protection
|
||||
limiter = Limiter(
|
||||
key_func=get_remote_address,
|
||||
default_limits=["200 per day", "50 per hour"]
|
||||
)
|
||||
|
||||
|
||||
def hash_password(password):
|
||||
"""
|
||||
@@ -36,4 +43,4 @@ def check_password(password_hash, password):
|
||||
Returns:
|
||||
bool: True if the password matches the hash, False otherwise.
|
||||
"""
|
||||
return check_password_hash(password_hash, password)
|
||||
return check_password_hash(password_hash, password)
|
||||
Reference in New Issue
Block a user