Skip to content

A robust, customizable Flask application template with SQLite. Features user authentication functionalities like login, registration, password reset via email. Ideal starting point for secure web applications.

License

Notifications You must be signed in to change notification settings

beephole/FlaskAuthFrame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


FlaskAuthFrame

β—¦ FlaskAuthFrame A perfect starting point for an app !

β—¦ Developed with the software and tools below.

JavaScript HTML5 Python


🎬Live Demo

You can see a live demo of the application running at FLASKAUTHFRAME


demovideo.mp4

πŸ“– Table of Contents



πŸ“ Overview

The project is a Flask application designed to provide a comprehensive user authentication framework. It supports fundamental features like user registration, login, email verification, and password resetting, thereby enhancing the security aspect of web applications. The use of Python libraries such as Flask-SQLAlchemy, Flask-Mail and Flask-Login streamline the creation of such secure environments. The project presents a valuable foundation for developers working on platforms requiring trustworthy user authentication and can expedite the initial development process significantly.


πŸ“¦ Features

Feature Description
βš™οΈ Architecture Implements the Model-View-Controller (MVC) architectural pattern. Uses Flask as the web framework for Python-based backend.
πŸ”— Dependencies Main dependencies include Flask, SQL Alchemy, and WTForms for form handling. Secured on HTTPS with Flask-Talisman.
🧩 Modularity Separate modules for routes, models, and forms to increase maintainability.
⚑️ Performance Efficient use of Flask and minimalistic design strategies for increased speed.
πŸ” Security Uses WTForms for CSRF protection and Flask Login for user session management.
πŸ”Œ Integrations Integrated with SQL Alchemy for object-relational mapping
πŸ“Ά Scalability The application’s scalable potential depends on the Flask application's capacity to handle increased traffic when deployed with gunicorn or similar.

πŸš€ Pre-installation Setup

Before installing the application:

  1. Environment Variables:

    • Fill in the necessary information at .env.example and Rename this file to .env after .

    • Use existing keys for tests or provide your own Keys for Producton. However, you must provide Gmail SMTP information.

  2. Gmail SMTP Setup:

    • You must generate a Gmail app password for your account:
      • Go to your Google Account.
      • Select Security.
      • Under "Signing in to Google," select App Passwords. You may need to sign in again.
      • Under "App Passwords", select the app dropdown and choose "Mail", and the device you want the app password to apply to and then select Generate.
      • Follow the instructions to enter the App Password. The App Password is the 16-character code in the yellow bar on your device.
      • For a detailed walkthrough, watch this Tutorial. Img how pass looks like , below ⬇️

    Here how password looks like !

πŸ”§ Installation

  1. Clone the FlaskAuthFrame.git repository:
git clone https://github.com/beephole/FlaskAuthFrame.git
  1. Change to the project directory:
cd FlaskAuthFrame
  1. Create a virtual environment:
python -m venv env
  1. Activate the virtual environment:

    • On Windows, run:
    .\env\Scripts\activate
    
    • On Unix or MacOS, run:
    source env/bin/activate
    
  2. Install the dependencies:

pip install -r requirements.txt
  1. Init Database:
python init.py

πŸ€– Running FlaskAuthFrame.git

To run the project, use the following command:

python app.py

Server will run at http://127.0.0.1:5000

output.mp4

For first time registering users Try it with 2 or 3 diff emails , gmail verificaiton email "

note that you have to confim the links in gmail in browser if running locally , on phone you need to open a tunnel with ngrok for testing

πŸ“‚ Repository Structure

└── FlaskAuthFrame.git/
    β”œβ”€β”€ .env.example
    β”œβ”€β”€ app.py
    β”œβ”€β”€ init.py
    β”œβ”€β”€ LICENSE
    β”œβ”€β”€ models.py
    β”œβ”€β”€ requirements.txt
    β”œβ”€β”€ static/
    β”‚   β”œβ”€β”€ assets/
    β”‚   β”œβ”€β”€ favicon.ico
    β”‚   └── img/
    └── templates/
        β”œβ”€β”€ change_password.html
        β”œβ”€β”€ emailverification.html
        β”œβ”€β”€ error.html
        β”œβ”€β”€ index.html
        β”œβ”€β”€ login.html
        β”œβ”€β”€ register.html
        β”œβ”€β”€ registration_successful.html
        β”œβ”€β”€ reset_password.html
        β”œβ”€β”€ reset_password_email.html
        └── reset_token.html

βš™οΈ Modules

Root
File Summary
app.py This Flask application allows user registration, login, and authentication for a web application. It includes email confirmation, password hashing for security, and password reset capabilities. It also provides CSRF protection and CORS policies. The app uses Flask-SQLAlchemy for database interactions, Flask-Mail for email services, and Flask-Login for handling user sessions. Login is required for certain routes. The code also handles errors and flashes messages for user feedback.
models.py This code represents the database model structure in an application, using Flask-SQLAlchemy. It defines three primary models: Role, User, and UserRoles. The Role model has fields for ID, name, and description. The User model has fields for user-related data like name, username, email, password, login data, and associated roles. Lastly, UserRoles model captures the many-to-many relationships between users and roles.
requirements.txt The code installs dependencies for a Flask web application. It features Flask for creating the application, Flask-WTF for forms, Werkzeug for utilities and services, Flask-Cors for handling Cross-Origin Resource Sharing, Flask-Security for authentication and authorization, pytz for timezone calculations, SQLAlchemy for SQL toolkit and ORM, and email-validator for email validation. It also uses python-dotenv to manage environment variables.
change_password.html This is a templated HTML file for a web application's "Change Password" page. It includes Bootstrap and Font Awesome for styling and icons. It uses Jinja2 for statement and variable handling within HTML. Users can input their old and new passwords. If any error messages exist, they are flashed on screen. The page also features a dark mode toggle, a back button, and a floating image button.
emailverification.html This HTML file is an email template used for email verification. It generates a styled email which contains a welcome message, a confirmation token link, and a footer. The email features an adjustable'Verify' button that recipients can click to confirm their email addresses during signup. It also offers a manual link for copy-pasting in the browser if the button fails. Custom session data is used to personalize the email by addressing recipients by their provided names.
error.html The code generates an error page displayed when a user attempts to access an expired link. Key features include an SVG image, a message advising users to check for accidental input errors, a link redirecting them to the login page, and a looping JavaScript function for an alternating animation on the SVG images. Styling is used to format the appearance of page elements and animations.
index.html The code is a Jinja2 templated HTML for a login page. It's styled with CSS and uses Bootstrap for responsive design. The functionalities include the display of flashed messages, switching to dark mode, handling user login session, redirecting for logout and password change, and showing a user's Github and Twitter profiles. Additionally, it shows a donation modal on button hover. The alert and modal have visibility controlled via JavaScript.
login.html This code is for a webpage with a login form. Main functions include a form to take email and password, options to register a new account and reset password, and a switch for light/dark modes. It also shows alerts for any messages, and hides them after 5 seconds. The form posts data to the'login' url. Styling is dynamic with CSS transitions.
register.html This HTML file sets up the registration page for a website. Users can fill out the form to register and create a new account. The form includes fields for first name, last name, email, password, and terms acceptance. The code also handles flash messages, an arrow-back option, a dark-mode toggle, and setup for a floating animation. Links for already-existing users to log in are included too. CSS and JS files are linked for styling and interactivity.
registration_successful.html The code constructs a HTML template to notify users of successful registration. It imports aesthetic CSS styles from multiple external sources, implements button scaling animations, and displays a congratulations header. It also informs users that a verification email has been sent with further instructions and provides links to major email providers.
reset_password.html The HTML code specifies a web page template for a password reset form, including stylization and animations. Essential elements include flashing messages for user feedback, an email input field, and a submit button for requesting password reset instructions. It also embeds interactive'Go back' and'Dark mode' buttons, and links for registration and homepage navigation. Additionally, it temporarily shows alert messages and features a floating image frame.
reset_password_email.html This is an HTML template for a password reset email. It is styled with a minimalistic, centered layout. The email greets the recipient, provides a reset link (dynamically inserted with the'reset_url' variable), and assures that no changes will be made without the user's action. Lastly, it appreciates the user's attention.
reset_token.html The HTML file represents a web page built for resetting a user's password. It provides form fields to enter a new password and confirm it. It uses Bootstrap and FontAwesome for styling and includes custom CSS for elements like alerts and button animations. The page operates in both light and dark modes. User messages, like errors, are flashed and automatically hidden after 5 seconds.

🀝 Contributing

Contributions are always welcome! Please follow these steps:

  1. Fork the project repository. This creates a copy of the project on your account that you can modify without affecting the original project.
  2. Clone the forked repository to your local machine using a Git client like Git or GitHub Desktop.
  3. Create a new branch with a descriptive name (e.g., new-feature-branch or bugfix-issue-123).
git checkout -b new-feature-branch
  1. Make changes to the project's codebase.
  2. Commit your changes to your local branch with a clear commit message that explains the changes you've made.
git commit -m 'Implemented new feature.'
  1. Push your changes to your forked repository on GitHub using the following command
git push origin new-feature-branch
  1. Create a new pull request to the original project repository. In the pull request, describe the changes you've made and why they're necessary. The project maintainers will review your changes and provide feedback or merge them into the main branch.

πŸ“„ License

This project is licensed under the ℹ️ MIT License. See the LICENSE-MIT file for additional info.


Hi, I'm Beephole! πŸ‘‹

πŸ”— Links

twitter


About

A robust, customizable Flask application template with SQLite. Features user authentication functionalities like login, registration, password reset via email. Ideal starting point for secure web applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published