Auth Service is a Flask-based RESTful application designed to streamline user authentication for web applications. It offers comprehensive features for user management, including user registration, login, and password reset, ensuring a secure and hassle-free user account management experience. Auth Service is containerized using Docker for easy deployment.
- Introduction
- Docker Process
- Installation
- Usage
- Configuration
- Features
- Contributing
- License
- Contact
- Acknowledgments
- Authors
Auth Service is designed to streamline user authentication. Whether you're building a small web app or a large-scale system, it helps you manage user accounts, store passwords securely, and handle password recovery.
This service is containerized using Docker for easy deployment and management. The Docker Compose configuration includes three services:
auth-service
: This is the main application service.auth-db
: A PostgreSQL database service for storing user data.pgadmin
: A PgAdmin service for database management.
The Docker Compose file (docker-compose.yml
) specifies the build process for the auth-service
container, the usage of pre-built images for the auth-db
and pgadmin
services, and the necessary environment variables for each service. To run Auth Service using Docker, follow these steps:
-
Clone the repository:
git clone https://github.com/munuhee/auth-service.git cd auth-service
-
Create a
.env
file on the root directory and set the necessary environment variables for theauth-service
. You can use the provided template and update it with your values.# Application Configuration FLASK_ENV=development # Set this to 'testing' or 'production' as needed # Authentication SECRET_KEY=your_secret_key_value REFRESH_SECRET_KEY=your_refresh_secret_key_value # Database SQLALCHEMY_DATABASE_URI=postgresql://<username>:<password>@<host>:<port>/<database> # Email Configuration MAIL_USERNAME=your_mail_username MAIL_PASSWORD=your_mail_password MAIL_DEFAULT_SENDER=your_mail_default_sender # PostgreSQL Configuration (auth-db service) POSTGRES_USER=your_postgres_user POSTGRES_PASSWORD=your_postgres_password POSTGRES_DB=your_database_name # PgAdmin Configuration (pgadmin service) PGADMIN_DEFAULT_EMAIL=your_pgadmin_email PGADMIN_DEFAULT_PASSWORD=your_pgadmin_password
Make sure to replace the variables with your actual configuration values.
-
Run the application using Docker Compose:
docker-compose up
The application will be accessible at http://localhost:5000
. Customize the configuration in config.py
to fit your needs.
To set up and run Auth Service locally (without Docker), follow the installation steps below
-
Clone the repository:
git clone https://github.com/munuhee/auth-service.git cd auth-service
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows, use 'venv\Scripts\activate'
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.env
file on the root directory and set the necessary environment variables.# Application Configuration FLASK_ENV=development # Set this to 'testing' or 'production' as needed # Authentication SECRET_KEY=your_secret_key_value REFRESH_SECRET_KEY=your_refresh_secret_key_value # Email Configuration MAIL_USERNAME=your_mail_username MAIL_PASSWORD=your_mail_password MAIL_DEFAULT_SENDER=your_mail_default_sender
Make sure to replace the variables with your actual configuration values.
-
Initialize the database and apply migrations:
flask db init flask db migrate flask db upgrade
-
Start the application:
python run.py
Auth Service provides the following endpoints for user registration, login, and password reset:
GET /api/status
: Check the health status of the application.POST /api/register
: Register a new user.POST /api/login
: Log in a user.POST /api/reset-password
: Initiate a password reset request, verify reset tokens, and reset passwords.
You can interact with these endpoints using a RESTful API client or within your application.
- User Registration: Register new users with unique usernames and email addresses.
- Password Management: Store and validate user passwords securely.
- Password Reset: Initiate password reset requests with email notifications.
- Health Status: Monitor the system's health with a dedicated endpoint.
If you'd like to contribute to this project, please follow these guidelines:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Implement your changes.
- Write tests to ensure your code functions correctly.
- Create a pull request, describing the changes you made.
This project is licensed under the MIT License.
For questions or suggestions, please visit my GitHub profile.
I'd like to acknowledge the following libraries, tools, and individuals who contributed to this project, including Docker for containerization:
- Flask: A lightweight and flexible micro web framework for Python.
- SQLAlchemy: An SQL toolkit and Object-Relational Mapping (ORM) library.
- Flask-Mail: An extension for sending email from your Flask application.
- Werkzeug: A WSGI utility library for Python.
- Python Community: For creating an amazing language and community.
-
Happy coding! 🚀