A ChaCC API module providing user authentication and management functionality.
- User registration and login
- JWT-based authentication
- Password hashing with bcrypt
- User profile management
- Admin user listing
- Service registration for other modules
cd plugins/authentication
python module/run_tests.py setupThis creates a virtual environment and installs dependencies.
# With venv
python module/run_tests.py test
# Without venv
python module/run_tests.py test --no-venvRun the module independently for development:
python module/run_tests.py standaloneThe module will be available at http://localhost:8001/auth/
SECRET_KEY: JWT secret key (use strong key in production)AUTHENTICATION_ENABLE_SELF_REGISTRATION: set toTrueorFalseto allow user to selft-register
AUTHENTICATION_DEFAULT_ADMIN_USERNAME: set username for automatic created accountAUTHENTICATION_DEFAULT_ADMIN_PASSWORD: set password for automatic created account
POST /register- Register new userPOST /login- Login and get JWT token
GET /me- Get current user profilePUT /me- Update current user profileDELETE /me- Delete current user accountGET /users- Admin: List all users
module/
├── __init__.py
├── main.py # Module setup
├── models.py # Database models and schemas
├── routes.py # API endpoints
├── auth.py # Authentication utilities
├── dev_context.py # Development context mock
├── context_factory.py # Context provider
├── tests/
│ └── test_module.py
└── run_tests.py # Development tools
The module uses a context factory to work in different environments:
- Development: Uses provided BackboneContext
- Production: Uses provided BackboneContext
- Testing: Minimal context for isolated testing
get_current_user: Dependency for protecting routes in other modules which you can get by calling ChaCCasync context.get_service("get_current_user")
- fastapi
- sqlalchemy
- passlib[bcrypt]
- python-jose[cryptography]
- pydantic