TorbatYar/backend/services/identity-access/README.md
Mortezakoohjani 800b0ba2c5 Deploy TorbatYar for torbatyar.ir with nginx multi-tenant routing.
Wire production domain, CORS for tenant subdomains, celery volume mounts, and nginx reverse proxy configs for apex, API, identity, auth, and wildcard tenants.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 21:43:33 +03:30

43 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Identity & Access Service
سرویس احراز هویت و دسترسی (فاز ۲) — SSO مرکزی با Keycloak.
## مسئولیت‌ها
- مدیریت پروفایل کاربر و عضویت tenant
- ارائه پیکربندی OIDC به frontend
- تبدیل authorization code به token (BFF)
- همگام‌سازی کاربران با Keycloak Admin API
## دیتابیس
`identity_access_db` (مستقل از Core — database-per-service)
## APIهای اصلی
| متد | مسیر | توضیح |
| --- | --- | --- |
| GET | `/health` | سلامت سرویس |
| GET | `/api/v1/auth/config` | پیکربندی OIDC (عمومی) |
| POST | `/api/v1/auth/token` | تبدیل code به token |
| GET | `/api/v1/auth/me` | کاربر جاری |
| POST | `/api/v1/users` | ثبت کاربر (admin) |
| POST | `/api/v1/tenants/{id}/members` | افزودن عضو tenant |
## اجرا
```bash
cd backend/services/identity-access
pip install -r requirements.txt
alembic upgrade head
uvicorn app.main:app --reload --port 8001
```
## تست
```bash
pytest -q
```
## SSO Flow
1. Frontend از `/api/v1/auth/config` آدرس Keycloak را می‌گیرد.
2. کاربر به Keycloak redirect می‌شود.
3. پس از login، callback با `code` به frontend برمی‌گردد.
4. Frontend کد را به `/api/v1/auth/token` می‌فرستد و token دریافت می‌کند.
5. همه سرویس‌ها (Core، CRM، ...) همان JWT را validate می‌کنند.