Skip to content

AuthX is a versatile and reusable authentication API built to work seamlessly with both Flask and FastAPI

License

Notifications You must be signed in to change notification settings

SCCSMARTCODE/AuthX

Repository files navigation

Project Name

AuthX

Project Description

AuthX is a versatile and reusable authentication API built to work seamlessly with both Flask and FastAPI. It supports multiple authentication methods, including traditional username/password login, OAuth 2.0 with social logins (Google, Facebook, GitHub, etc.), two-factor authentication (2FA), passwordless login, and more. AuthX is designed with security and flexibility in mind, making it easy to integrate into various applications while providing robust user management and role-based access control (RBAC).

AuthX

AuthX is a reusable and modular authentication API designed to work with both Flask and FastAPI. It offers a wide range of authentication methods, making it an ideal solution for projects that require secure and flexible user authentication.

Features

  • Username/Password Authentication: Secure user registration and login with hashed passwords.
  • OAuth 2.0: Support for social logins with Google, Facebook, GitHub, and more.
  • Two-Factor Authentication (2FA): Optional second layer of security with OTP via SMS or email.
  • Passwordless Authentication: Magic link or email link login for a seamless user experience.
  • JWT Authentication: Token-based authentication for stateless sessions.
  • API Key Authentication: Secure service-to-service communication using API keys.
  • Role-Based Access Control (RBAC): User roles and permissions management.
  • Single Sign-On (SSO): Support for enterprise-level SSO with protocols like SAML and OpenID Connect.
  • Modular Design: Easily extend or customize the API to fit your specific needs.

Getting Started

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/authx.git
    cd authx
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate   # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Set up environment variables: Create a .env file in the project root with your configuration. Example:

    FLASK_APP=authx_flask
    FLASK_ENV=development
    SECRET_KEY=your_secret_key
    SQLALCHEMY_DATABASE_URI=sqlite:///authx.db
  5. Run the database migrations:

    flask db upgrade

Usage

Flask Implementation

  1. Start the Flask server:

    flask run

    The API will be available at http://127.0.0.1:5000/.

  2. Explore the available endpoints and start integrating AuthX into your Flask-based project.

FastAPI Implementation

  1. Start the FastAPI server:

    uvicorn authx_fastapi:app --reload

    The API will be available at http://127.0.0.1:8000/.

  2. Explore the available endpoints via the automatically generated Swagger UI at http://127.0.0.1:8000/docs.

Authentication Methods

  • Username/Password: Register and log in users with traditional credentials.
  • OAuth 2.0: Enable social logins with popular providers like Google, Facebook, and GitHub.
  • 2FA: Add an extra layer of security with two-factor authentication.
  • Passwordless: Allow users to log in without a password using a magic link.
  • JWT: Secure API requests with token-based authentication.
  • API Key: Protect your services with API key-based authentication.

Configuration

You can configure various aspects of AuthX by editing the .env file. Key configuration options include:

  • Database URI: Specify the database connection string.
  • Secret Key: Set the secret key for secure session management.
  • OAuth Providers: Configure credentials for OAuth providers.

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss any changes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to the open-source community for providing tools and libraries that made this project possible.
  • Special thanks to the Flask and FastAPI teams for their amazing work on these frameworks.

About

AuthX is a versatile and reusable authentication API built to work seamlessly with both Flask and FastAPI

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published