A secure web-based authentication system developed using Python Flask, MariaDB, SQLAlchemy, and bcrypt. This project demonstrates modern authentication techniques, secure password storage, session management, and web security best practices.
The Secure Login System is a cybersecurity-focused web application that allows users to register, authenticate, and manage sessions securely. The system implements password hashing using bcrypt and stores user credentials in a MariaDB database.
The primary objective of this project is to demonstrate secure authentication mechanisms while following secure coding principles and protecting against common web-based attacks.
- Implement secure user registration and login functionality.
- Store passwords securely using bcrypt hashing.
- Prevent duplicate account creation.
- Manage authenticated sessions securely.
- Demonstrate database integration using MariaDB.
SecureLoginSystem/
│
├── templates/
│ ├── login.html
│ ├── register.html
│ └── dashboard.html
│
├── static/
│ └── style.css
│
├── screenshots/
│
├── app.py
├── requirements.txt
├── LICENSE
└── README.md
-
Create a new account using:
- Username
- Email Address
- Password
- Secure login system
- Password verification using bcrypt
- Session-based authentication
- Passwords are never stored in plain text
- bcrypt hashing implemented
- Strong password validation
- Duplicate username prevention
- Duplicate email prevention
- Input validation
- Secure session creation
- Session-based user authentication
- Logout functionality
- Login success notifications
- Registration success notifications
- Error handling messages
- Invalid credential alerts
- Password Hashing (bcrypt)
- SQL Injection Protection
- Session Management
- Authentication & Authorization
- Secure Database Storage
- Input Validation
- MariaDB Database
- SQLAlchemy ORM
- Automated table creation
- HTML5
- CSS3
- JavaScript
- Python
- Flask
- MariaDB
- SQLAlchemy
- bcrypt
git clone https://github.com/your-username/SecureLoginSystem.git
cd SecureLoginSystempython3 -m venv venvActivate:
source venv/bin/activatepip install -r requirements.txtor
pip install flask flask_sqlalchemy pymysql bcryptsudo systemctl start mariadbsudo mariadbCREATE DATABASE secure_login;CREATE USER 'flaskuser'@'localhost'
IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES
ON secure_login.*
TO 'flaskuser'@'localhost';
FLUSH PRIVILEGES;python3 app.pyOutput:
* Running on http://127.0.0.1:5000
Open:
http://127.0.0.1:5000
User Registration
│
▼
Input Validation
│
▼
Duplicate Check
│
▼
Password Hashing
│
▼
Store in MariaDB
User Login
│
▼
Retrieve User
│
▼
Verify Password
│
▼
Create Session
│
▼
Dashboard Access
Logout
│
▼
Destroy Session
│
▼
Redirect To Login
Passwords are hashed using bcrypt before being stored in the database.
Example:
hashed_password = bcrypt.hashpw(
password.encode('utf-8'),
bcrypt.gensalt()
)The project uses SQLAlchemy ORM, which automatically utilizes parameterized queries.
Example:
User.query.filter_by(
username=username
).first()Authenticated users are tracked using Flask sessions.
Example:
session['user'] = user.username| Field | Type |
|---|---|
| id | Integer |
| username | String |
| String | |
| password | String |
| created_at | DateTime |
| id | username | |
|---|---|---|
| 1 | manjeetkumar | manjeetkumar123@gmail.com |
Potential improvements:
- Google Authenticator
- Time-based OTP
- QR Code Integration
- Email Verification
- Password Reset Links
- Verify accounts before activation
- Brute-force attack prevention
- Account lockout mechanism
- Admin Dashboard
- User Dashboard
Contributions, suggestions, and feedback are always welcome. Feel free to open an issue or submit a pull request.
Manjeet Kumar
Cyber Security Engineering Student
This project is licensed under the MIT License. See the LICENSE file for details.