Integration layer for Vexen systems (user, rbac, auth)
Project description
vexen-core
Integration layer for the Vexen system suite (user, rbac, auth).
Overview
vexen-core provides a unified container that integrates three independent Vexen systems:
- vexen-user: User management with hexagonal architecture
- vexen-rbac: Role-Based Access Control system
- vexen-auth: Authentication with JWT tokens
Installation
pip install vexen-core
This will automatically install all three systems as dependencies.
Quick Start
import asyncio
from vexen_core import VexenConfig, VexenContainer
async def main():
# Create configuration
config = VexenConfig(
database_url="postgresql+asyncpg://user:pass@localhost/db",
secret_key="your-secret-key-change-in-production",
algorithm="HS256",
echo=False
)
# Use context manager (recommended)
async with VexenContainer(config) as vexen:
# Access all three systems
user_system = vexen.user
rbac_system = vexen.rbac
auth_system = vexen.auth
# Use the services
# users = await vexen.user.service.list()
# roles = await vexen.rbac.roles.list()
# auth_response = await vexen.auth.service.login(request)
if __name__ == "__main__":
asyncio.run(main())
Configuration
The VexenConfig dataclass accepts the following parameters:
@dataclass
class VexenConfig:
# Database configuration
database_url: str
echo: bool = False
pool_size: int = 5
max_overflow: int = 10
# Authentication configuration
secret_key: str
algorithm: str = "HS256"
access_token_expires_minutes: int = 15
refresh_token_expires_days: int = 30
Usage
User Management
from vexen_user.application.dto import CreateUserRequest
async with VexenContainer(config) as vexen:
# Create a user
request = CreateUserRequest(
email="john@example.com",
name="John Doe"
)
response = await vexen.user.service.create(request)
if response.success:
print(f"User created: {response.data.id}")
RBAC
from vexen_rbac.application.dto import CreateRoleRequest
async with VexenContainer(config) as vexen:
# Create a role
request = CreateRoleRequest(
name="admin",
description="Administrator role"
)
response = await vexen.rbac.roles.create(request)
if response.success:
print(f"Role created: {response.data.id}")
Authentication
from vexen_auth.application.dto import LoginRequest
async with VexenContainer(config) as vexen:
# Login
request = LoginRequest(
email="john@example.com",
password="SecurePassword123"
)
response = await vexen.auth.service.login(request)
if response:
print(f"Access token: {response.access_token}")
print(f"User ID: {response.user_id}")
Architecture
System Integration
The VexenContainer initializes all three systems with shared configuration:
- User System - Initialized first, provides user repository
- RBAC System - Initialized second, manages roles and permissions
- Auth System - Initialized last, configured to use the user repository
Dependency Injection
The auth system is automatically configured to work with the user repository:
# Automatic integration
async with VexenContainer(config) as vexen:
# Auth system can access user information
# without tight coupling to user service
pass
Manual Lifecycle
If you need more control over initialization:
vexen = VexenContainer(config)
await vexen.init()
try:
# Use systems
pass
finally:
await vexen.close()
API Reference
VexenContainer
Properties
user: VexenUser- Access to user management systemrbac: RBAC- Access to RBAC systemauth: VexenAuth- Access to authentication system
Methods
async init()- Initialize all systemsasync close()- Close all systems and cleanup resourcesasync __aenter__()- Context manager entryasync __aexit__()- Context manager exit
Examples
See the examples directory for complete examples:
basic_usage.py- Basic integration example- More examples coming soon...
Development
Running Tests
pytest
Code Quality
# Format code
ruff format .
# Lint code
ruff check . --fix
License
MIT
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vexen_core-0.1.3.tar.gz.
File metadata
- Download URL: vexen_core-0.1.3.tar.gz
- Upload date:
- Size: 37.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
beba137b578e41bd2438cea37f45b8d6320d8e6e64fb78314e8ed3c167adc7c6
|
|
| MD5 |
16e9108f291b4eb6f8677960df2ab671
|
|
| BLAKE2b-256 |
061e7bfb4eaab7876379d916931fb41d00c1fcccf632e40e3c73d680a792a6b2
|
Provenance
The following attestation bundles were made for vexen_core-0.1.3.tar.gz:
Publisher:
python-publish.yml on vexen-labs/vexen-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vexen_core-0.1.3.tar.gz -
Subject digest:
beba137b578e41bd2438cea37f45b8d6320d8e6e64fb78314e8ed3c167adc7c6 - Sigstore transparency entry: 737595586
- Sigstore integration time:
-
Permalink:
vexen-labs/vexen-core@ffbda0950a3c20dc85d5ca304c31ef9893419347 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/vexen-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ffbda0950a3c20dc85d5ca304c31ef9893419347 -
Trigger Event:
release
-
Statement type:
File details
Details for the file vexen_core-0.1.3-py3-none-any.whl.
File metadata
- Download URL: vexen_core-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8301919e9028c5c0306ab11e84f02f1d52f3ade7738d9397ad8da3c1e4d06db
|
|
| MD5 |
ad5d85a5cff84ada77884ccad4fd302f
|
|
| BLAKE2b-256 |
be4b8abe4c5608caecf0a5315e720551a1c9179556dde2611cbfbcc39eb0f553
|
Provenance
The following attestation bundles were made for vexen_core-0.1.3-py3-none-any.whl:
Publisher:
python-publish.yml on vexen-labs/vexen-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vexen_core-0.1.3-py3-none-any.whl -
Subject digest:
d8301919e9028c5c0306ab11e84f02f1d52f3ade7738d9397ad8da3c1e4d06db - Sigstore transparency entry: 737595587
- Sigstore integration time:
-
Permalink:
vexen-labs/vexen-core@ffbda0950a3c20dc85d5ca304c31ef9893419347 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/vexen-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ffbda0950a3c20dc85d5ca304c31ef9893419347 -
Trigger Event:
release
-
Statement type: