Skip to content

Commit 7110b8e

Browse files
committed
feat: 📝 Write readme
1 parent c5081ca commit 7110b8e

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Rusty Valkey Forward Auth
2+
3+
Lightweight API Key management solution. Supports OAuth2/OIDC authentication, Valkey storage, and Traefik forward auth.
4+
5+
Can be useful to provide an easy and old-school API key authentication mechanism to a HTTP service behind Traefik.
6+
7+
## Features
8+
9+
- **Forward Auth**: Request validation for Traefik proxy
10+
- **Token Management**: Create, list, and delete API tokens via OAuth2-secured APIs
11+
- **Token Storage**: Tokens stored as blake3 hashes in Valkey with Lua script synchronization
12+
- **Web UI**: React-based interface for user self-service token management
13+
- **OAuth2/OIDC**: Integrated OAuth2 resource server for API and UI authentication
14+
- **Multi-user**: Admin APIs for managing tokens across users, self-service APIs for personal tokens
15+
16+
## Stack
17+
18+
- **Backend**: Stateless HTTP API in Rust
19+
- **Frontend**: Web UI in TypeScript + React + Vite
20+
- **Storage**: Valkey, a Redis fork, for token storage
21+
22+
## Quick Start
23+
24+
### Prerequisites
25+
26+
- Rust 1.90+
27+
- Node.js 24+
28+
- Valkey on `localhost:6379`
29+
- An OAuth2/OIDC provider
30+
31+
### Configuration
32+
33+
Create `settings.toml` or use environment variables:
34+
35+
```toml
36+
[http]
37+
address = "127.0.0.1"
38+
port = 8080
39+
40+
[valkey]
41+
url = "redis://localhost:6379"
42+
43+
[oauth]
44+
issuer_url = "https://your-oauth-provider"
45+
# OR: jwks_url = "https://your-jwks-endpoint"
46+
47+
[oauth.claims]
48+
subject = "sub"
49+
groups = "groups"
50+
51+
[oauth.admin]
52+
group = "admin"
53+
54+
[frontend]
55+
oidc_authority = "https://your-oauth-provider"
56+
oidc_client_id = "your-client-id"
57+
```
58+
59+
### Running
60+
61+
```bash
62+
# Build and run
63+
cargo run
64+
```
65+
66+
The service runs on `http://localhost:8080` and serves the frontend UI at `/`.
67+
68+
## Development
69+
70+
### Setup
71+
72+
Install pre-commit hooks:
73+
74+
```bash
75+
pre-commit install
76+
```
77+
78+
### Backend
79+
80+
```bash
81+
cargo check # Validate
82+
cargo clippy # Lint
83+
cargo clippy --test # Lint tests
84+
cargo fmt # Format
85+
cargo test # Test (requires Valkey on localhost:6379)
86+
```
87+
88+
### Frontend
89+
90+
Build frontend before running the service:
91+
92+
```bash
93+
cd frontend
94+
npm install
95+
npm run build
96+
```
97+
98+
Or run dev server separately:
99+
100+
```bash
101+
npm run dev # Dev server on http://localhost:5173
102+
npm run lint # Linting
103+
```
104+
105+
Set `VITE_API_BASE_URL` to point to your backend API (defaults to `http://localhost:8080`).
106+
107+
## Deployment
108+
109+
### Docker
110+
111+
```bash
112+
docker build -t rusty-valkey-forward-auth .
113+
docker run -e VALKEY_URL=redis://host.docker.internal:6379 \
114+
-p 8080:8080 \
115+
rusty-valkey-forward-auth
116+
```
117+
118+
Multi-stage build: Rust backend + Node.js frontend compiled, served from distroless runtime.
119+
120+
### Kubernetes (Helm)
121+
122+
```bash
123+
helm install rvfa ./charts/rusty-valkey-forward-auth \
124+
--set valkey.url=redis://valkey:6379 \
125+
--set oauth.issuerUrl=https://your-oauth-provider
126+
```
127+
128+
See [charts/rusty-valkey-forward-auth/](charts/rusty-valkey-forward-auth/) for full Helm configuration.
129+
130+
## Traefik Integration
131+
132+
Configure Traefik to use this service for forward authentication:
133+
134+
```yaml
135+
http:
136+
middlewares:
137+
rusty-valkey-auth:
138+
forwardAuth:
139+
address: "http://rusty-valkey-forward-auth:8080/forward-auth"
140+
```
141+
142+
## Endpoints
143+
144+
- `/` - Frontend UI (OAuth2 secured)
145+
- `/docs` - API documentation
146+
147+
### API Admin Endpoints (requires admin group)
148+
149+
- `POST /api/users/{sub}/tokens` - Create token for user
150+
- `GET /api/users/{sub}/tokens` - List user tokens
151+
- `DELETE /api/users/{sub}/tokens/{id}` - Delete user token
152+
153+
### API User Endpoints (authenticated)
154+
155+
- `GET /api/me/tokens` - List own tokens
156+
- `POST /api/me/tokens` - Create own token
157+
- `DELETE /api/me/tokens/{id}` - Delete own token
158+
159+
### API Service Endpoints
160+
161+
- `GET /health/live` - Liveness probe
162+
- `GET /health/ready` - Readiness probe
163+
- `GET /forward-auth` - Forward auth validator
164+
165+
## License
166+
167+
This project is licensed under the [Apache License 2.0](LICENSE).

0 commit comments

Comments
 (0)