SafeLogin is a Flask-based web application that provides secure user authentication with modern security features.
✅ Secure Password Storage – Hashed with bcrypt
✅ Two-Factor Authentication (2FA) – Google Authenticator support
✅ Session Management – Secure and configurable sessions
✅ Rate Limiting – Protects against brute-force attacks
✅ SQLite Database – Simple and efficient user storage
✅ Static File Security – QR code is accessible only during registration
- Passwords are hashed (never stored in plain text).
- Two-Factor Authentication (2FA) provides extra security.
- Rate Limiting prevents excessive login attempts.
- Sessions are securely stored and managed.
- Static files (QR codes) are protected to avoid unauthorized access.
git clone https://github.com/your-user/safelogin.git
cd safeloginpython -m venv venv
source venv/bin/activate # macOS & Linux
venv\Scripts\activate # Windowspip install -r requirements.txtMake sure the SQLite database is set up correctly. You can manually create it, or it will be created automatically when the app runs.
python app.py🔗 Now visit: http://127.0.0.1:5000
- Go to
http://127.0.0.1:5000/register. - Enter a username, email, and password.
- Scan the QR code for 2FA (Google Authenticator).
- Enter the generated authentication code.
- 🎉 Done! You are now registered.
- Visit
http://127.0.0.1:5000/login. - Enter your email and password.
- Enter your 2FA code from Google Authenticator.
- ✅ If successful, you will be redirected to the dashboard.
SafeLogin/
│── database/ #folder fpr databases
│ ├── users.db # storing user data hashed
│── static/ # Static files (CSS, JS, images)
│ ├── style.css # Styling
│ ├── flash-message.js # Setting Falsh messages
│ ├── password-check.js # Checking PW stenght
│── templates/ # HTML templates for Flask
│ ├── login.html # Login page
│ ├── register.html # Registration page
│ ├── 2fa.html # 2FA verification page
│ ├── dashboard.html # Dashboard after login
│── utils/ # Helper functions for security & database
│ ├── database.py # SQLite database connection
│ ├── security.py # Password hashing and 2FA functions
│── app.py # Main Flask application
│── config.py # Configuration settings
│── requirements.txt # Dependencies
│── README.md # Documentation
Modify config.py to customize settings:
SECRET_KEY = "your-secret-key"
SESSION_TYPE = "filesystem"
RATE_LIMIT = "5 per minute" # Limits to 5 requests per minute🔴 Important: Replace SECRET_KEY with a strong random value!
If you have any suggestions, bug reports, or pull requests, feel free to contribute! 🎉
Flask==2.2.3
Flask-Limiter==2.1.0
Flask-SQLAlchemy==3.0.3
pyotp==2.8.0
bcrypt==4.0.1
qrcode==7.3.1
werkzeug==2.3.7
flask_session
pillow