SchemaX is a robust and modern authentication service built with FastAPI. It provides a secure foundation for user management, featuring JWT-based authentication, refresh token rotation, and secure password handling using industry standards.
- FastAPI Powered: High performance, easy to learn, fast to code, ready for production.
- Secure Authentication: Implements OAuth2 password flow with Bearer tokens.
- JWT Strategy: Utilizes short-lived access tokens and long-lived refresh tokens for enhanced security.
- Password Security: Strong password hashing using
bcryptwith salt generation. - Database ORM: SQLAlchemy for robust database interactions.
- Interactive Docs: Automatic Swagger UI and ReDoc integration.
This project relies on a modern Python stack:
- FastAPI: The core web framework.
- SQLAlchemy: SQL toolkit and Object Relational Mapper.
- PyJWT: For generating and verifying JSON Web Tokens.
- Bcrypt: For secure password hashing.
- Pydantic: For data validation and settings management.
- Uvicorn: A lightning-fast ASGI server.
-
Clone the repository
git clone <repository-url> cd SchemaX
-
Create a virtual environment
# Windows Chnage name in pyproject.toml file
-
Install dependencies
uv sync .venv\Scripts\activate
-
Configuration Ensure you have configured your environment variables (e.g.,
SECRET_KEY,DATABASE_URL) in a.envfile or your system environment.
You can start the server using the provided batch script or directly via Uvicorn.
Using the batch script (Windows):
start.batUsing Uvicorn directly:
uvicorn main:app --reloadOnce the server is running, you can explore the API endpoints:
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
The authentication system is designed with security in mind:
- Register: Create a new account via
POST /auth/register. - Login: Authenticate via
POST /auth/loginto receive anaccess_tokenandrefresh_token. - Access: Use the
access_tokenin theAuthorization: Bearer <token>header for protected routes. - Refresh: When the access token expires, send the
refresh_tokentoPOST /auth/refreshto obtain a new pair.
Generated for SchemaX