# authx
**Repository Path**: tpig/authx
## Basic Information
- **Project Name**: authx
- **Description**: FastAPI JWT 认证和授权扩展,持续更新中
- **Primary Language**: Python
- **License**: MIT
- **Default Branch**: 0.X.X-fix
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2024-10-24
- **Last Updated**: 2024-10-24
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# AuthenticationX 💫

Ready-to-use and customizable Authentications and Oauth2 management for FastAPI ⚡
---
**Source Code**:
**Documentation**:
---
Add a Fully registration and authentication or authorization system to your
[FastAPI](https://fastapi.tiangolo.com/) project. **AuthX** is designed to be as
customizable and adaptable as possible.
## Features 🔧
- [x] Support Python 3.9+.
- [x] Extensible base user model.
- [x] Ready-to-use register, login, reset password and verify e-mail routes.
- [x] Ready-to-use Social login and Oauth2 routes.
- [x] Full Configuration and customization.
- [x] Ready-to-use social OAuth2 login flow.
- [x] Middleware Support for Oauth2 using `Authlib` and Starlette.
- [x] Dependency callable to inject current user in route.
- [x] Pluggable password validation
- [x] Using Captcha Service.
- [x] Implements the `HMAC` algorithm And `Hashlib` library.
- [x] Using Email Service. (SMTP)
- [x] Extensible Error Handling
- [x] High level API to manage users, roles and permissions
- [x] Using Redis as a session store & cache.
- [x] Support HTTPCache.
- [x] Customizable database backend:
- [x] MongoDB async backend included thanks to
[mongodb/motor](https://github.com/mongodb/motor)
- [x] SQLAlchemy backend included thanks to
[Encode/Databases](https://github.com/encode/databases)
- [x] Multiple customizable authentication backend:
- [x] JWT authentication backend included
- [x] Cookie authentication backend included
- [x] Full OpenAPI schema support, even with several authentication backend.
- [x] Provide a Docstring for each class and function.
- [x] Support Sessions and Pre-built CRUD functions and Instance to launch
Redis.
- [x] Support SocketIO.
- [x] Support Middleware of [pyinstrument](https://pyinstrument.readthedocs.io/)
to check your service performance.
- [x] Support Middleware for collecting and exposing [Prometheus](https://prometheus.io/) metrics.
**Note:** Check [Release Notes](https://authx-v0.yezz.me/release/).
## Project using 🚀
```python
from fastapi import Depends, FastAPI
from authx import Authentication, User, RedisBackend
app = FastAPI()
# Set up Authentication & Authorization
auth = Authentication()
# Set up Pre-configured Routes
app.include_router(auth.auth_router, prefix="/api/users")
app.include_router(auth.social_router, prefix="/auth")
app.include_router(auth.password_router, prefix="/api/users")
app.include_router(auth.admin_router, prefix="/api/users")
app.include_router(auth.search_router, prefix="/api/users")
# Set Redis Cache
auth.set_cache(RedisBackend)
# Set Anonymous User
@app.get("/anonym")
def anonym_test(user: User = Depends(auth.get_user)):
pass
# Set Authenticated User
@app.get("/user")
def user_test(user: User = Depends(auth.get_authenticated_user)):
pass
# Set Admin User (Only for Admins)
@app.get("/admin", dependencies=[Depends(auth.admin_required)])
def admin_test():
pass
```
## Contributors and sponsors ✨☕️
[](#contributors-)
Thanks goes to these wonderful people
([emoji key](https://allcontributors.org/docs/en/emoji-key)):
This project follows the
[all-contributors](https://github.com/all-contributors/all-contributors)
specification. Contributions of any kind welcome!
## Links 🚧
- [Homepage](https://authx-v0.yezz.me/)
- [FAQ](https://authx-v0.yezz.me/faq/)
- [Release - AuthX](https://authx-v0.yezz.me/release/)
- [MIT License](https://authx-v0.yezz.me/license/)
- [Code of Conduct](https://authx-v0.yezz.me/code_of_conduct/)
- [Contributing](https://authx-v0.yezz.me/contributing/)
- [Help - Sponsors](https://authx-v0.yezz.me/help/)
## License 📝
This project is licensed under the terms of the MIT License.