flask-authentication-service

Simple Flask-based authentication service providing user login, registration, and token management with MongoDB integration.

Stars
3
Committers
2

πŸš€ Simple Flask Authentication Service

Welcome to your new go-to Flask-based authentication service! This streamlined solution offers a robust foundation for mastering authentication essentials. With built-in features like user login, registration, token management, and MongoDB integration, it’s designed to be user-friendly and versatile.


🌟 Key Features

  • πŸ” User Login: Securely authenticate users with password verification.
  • πŸ“ User Registration: Effortlessly create new user accounts.
  • 🎫 Token Generation: Issue secure tokens upon successful login for access control.
  • ⏳ Token Expiration: Manage token validity to enhance security.
  • 🌍 Language Agnostic: Seamlessly integrates with projects in any programming language.
  • πŸ’Ύ MongoDB Integration: Uses MongoDB and an Object-Document Mapper (ODM) for reliable data persistence.

πŸš€ Getting Started

πŸ“‹ Prerequisites

Ensure you have the following:

πŸƒβ€β™‚οΈ Running the Service

  1. Clone the Repository:

    git clone https://github.com/your-username/flask-authentication-service.git
    
  2. Navigate to the Project Directory:

    cd flask-authentication-service
    
  3. Install Dependencies:

    pip install -r requirements.txt
    
  4. Start the Server:

    python server.py
    
  5. Access the Service: Your authentication service will be available at localhost:9999 (port is customizable).

πŸ“‘ API Endpoints

Method Path Description
POST /login Login a user and obtain a token (provide id and password in the request body).
POST /register Register a new user (provide id and password in the request body).
POST /getUserIdWithToken Retrieve the user ID associated with a specific token (provide token in the request body).
POST /isTokenExpired Check if a token has expired (provide token in the request body).

πŸ’‘ Example Usage (with cURL)

Login:

curl -X POST -H "Content-Type: application/json" -d '{"id": "your_user_id", "password": "your_password"}' http://localhost:9999/login

Register:

curl -X POST -H "Content-Type: application/json" -d '{"id": "new_user_id", "password": "new_user_password"}' http://localhost:9999/register

Feel free to explore, customize, and make this service your own. Happy coding! πŸ˜„