Table of Contents
- Features
- Installation
- Quick Start
- Core Types
- Framework Integration
- Extending Users
- RBAC Permissions
- Code Coverage
Features
- Multiple Auth Methods — Telegram, Email, Phone authentication out of the box
- JWT Claims — Type-safe claims with expiration and role checking
- RBAC Permissions — Fine-grained permission system with bitflags
- Framework Extractors — Zero-boilerplate auth for Axum and Actix-web
- Projections — Type-safe views that prevent accidental data leaks
- Extensible —
extend_user!macro for application-specific fields - Entity-Derive Integration — Auto-generated DTOs via entity-derive
Installation
[]
= { = "0.1", = ["axum"] }
Available Features
| Feature | Description |
|---|---|
postgres |
PostgreSQL support via sqlx |
api |
OpenAPI schema generation via utoipa |
validate |
Validation derives via validator |
axum |
Axum framework extractors |
actix |
Actix-web framework extractors |
Note:
axumandactixfeatures are mutually exclusive.
Quick Start
use ;
// Create user from authentication
let user = from_telegram;
let user = from_email;
let user = from_phone;
// Create JWT claims
let exp = as usize;
let claims = new;
// Check permissions
assert!;
assert!;
Core Types
Entity
| Type | Description |
|---|---|
RUser |
Core user entity with all fields |
Claims |
JWT claims for authentication |
Projections
| Type | Description |
|---|---|
RUserPublic |
Safe for API responses (excludes sensitive data) |
RUserAuth |
For JWT/session context (includes role) |
DTOs
| Type | Description |
|---|---|
CreateUserRequest |
Create new user |
UpdateProfileRequest |
Update user profile |
BindTelegram |
Bind Telegram account |
BindEmail |
Bind email address |
BindPhone |
Bind phone number |
Framework Integration
Axum
use ;
use ;
async
let app = new.route;
Actix-web
use ;
use Claims;
async
Extending Users
Use the extend_user! macro for application-specific fields:
use ;
use Uuid;
extend_user!
let user = from_telegram
.name
.then
.company_id
.department
.build;
// Access RUser fields via Deref
assert!;
RBAC Permissions
Fine-grained permission system:
use ;
// Check role permissions
let role = Premium;
assert!;
assert!;
// Admin has all permissions
let admin = Admin;
assert!;
// Custom permission checks in Claims
let claims = new;
assert!;
Permission Flags
| Permission | Description |
|---|---|
READ |
Read access |
WRITE |
Write access |
DELETE |
Delete access |
ADMIN |
Administrative access |
Code Coverage
We maintain high test coverage to ensure reliability. Below are visual representations of our codebase coverage:
Sunburst
The inner circle represents the entire project. Moving outward: folders, then individual files. Size = number of statements, color = coverage percentage.
Grid
Each block represents a file. Size = number of statements, color = coverage level (green = high, red = low).
Icicle
Hierarchical view: top = entire project, descending through folders to individual files. Size and color represent statements and coverage.
License
MIT