Skip to content

ADKA2006/Flask_Login-Module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask Login Module

A simple and secure login/registration module built with Flask, Socket.IO, and MySQL/MariaDB.

Features

  • User registration with validation
  • Secure password hashing using bcrypt
  • User login with rate limiting (3 failed attempts = 5 minute lockout)
  • Real-time communication using Socket.IO
  • MySQL/MariaDB database integration

Installation Steps

1. Install Python Dependencies

pip install -r requirements.txt

2. Setup Database

Create database and user in MySQL/MariaDB:

CREATE DATABASE login_module_db;
CREATE USER 'login_user'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON login_module_db.* TO 'login_user'@'localhost';
FLUSH PRIVILEGES;

Run the setup script:

mysql -u login_user -p login_module_db < setup_database.sql

3. Configure Application

Edit backend.py and update:

DB_CONFIG = {
    'user': 'login_user',
    'password': 'your_secure_password',
    'host': 'localhost',
    'port': 3306,
    'database': 'login_module_db'
}

app.config['SECRET_KEY'] = 'your-secure-random-key-here'

4. Run the Server

python backend.py

5. Access Application

Open browser: http://localhost:4000

File Structure

  • backend.py - Main Flask application
  • static/script.js - Frontend JavaScript
  • static/style.css - Styling
  • templates/index.html - HTML template
  • setup_database.sql - Database schema
  • requirements.txt - Python dependencies

Usage

  1. Register: Click "Register" tab, enter username (3+ chars) and password (6+ chars)
  2. Login: Click "Login" tab, enter credentials

Security Features

  • Password hashing with bcrypt
  • Rate limiting (3 failed attempts = 5 min lockout)
  • Session management
  • SQL injection protection
  • Input validation

Customization

  • Change port: Modify port in socketio.run()
  • Adjust rate limiting: Modify timeout in cleanup_login_attempts()
  • Customize UI: Edit static/style.css and templates/index.html

Flask_Login-Module

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published