Skip to content

Commit 2d8d7d4

Browse files
Update README and documentation for email verification and role management
- Enhanced README to reflect the introduction of email verification and hybrid RBAC. - Updated API documentation to clarify login requirements and JWT claims, including new roles and email verification processes. - Added details on the X-Tenant-Id header and its significance for SystemAdmin operations. - Revised deployment documentation to include email verification settings and their implications in production. - Introduced new file for temporary cookies generated during development.
1 parent 88fbcae commit 2d8d7d4

5 files changed

Lines changed: 555 additions & 159 deletions

File tree

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Multi-Tenant Platform
22

3-
.NET **10** multi-tenant SaaS API with JWT authentication, permission-based RBAC, tenant isolation, and automated production deploys.
3+
.NET **10** multi-tenant SaaS API with JWT authentication, hybrid RBAC, complete tenant isolation, email verification, and automated production deploys.
44

55
## Documentation
66

77
| Document | Description |
88
|----------|-------------|
9-
| [docs/PROJECT.md](docs/PROJECT.md) | Architecture, auth, data model, migrations & seeds |
10-
| [docs/API.md](docs/API.md) | v1 endpoints, envelope, login, profiles, addresses |
9+
| [docs/PROJECT.md](docs/PROJECT.md) | Architecture, auth model, tenant isolation, data model, migrations & seeds |
10+
| [docs/API.md](docs/API.md) | v1 endpoints, envelope, login, email verification, invitations, profiles, addresses |
1111
| [docs/DEPLOYMENT.md](docs/DEPLOYMENT.md) | GitHub Actions → MonsterASP.NET (FTP) production deploy |
1212

1313
## How it works (workflow)
@@ -26,8 +26,8 @@
2626

2727
On every app start (local or production):
2828

29-
1. **Migrations** — pending EF migrations from `__EFMigrationsHistory` are applied (`ApplyMigrationsOnStartup`).
30-
2. **Seeds** — pending versioned seeds from `SeedHistory` are applied (`ApplySeedsOnStartup`). Already-applied seeds are skipped.
29+
1. **Migrations** — pending EF migrations from `__EFMigrationsHistory` are applied.
30+
2. **Seeds** — pending versioned seeds from `SeedHistory` are applied. Already-applied seeds are skipped.
3131

3232
Schema baseline: single migration **`InitialCreate`**. Seed versions are tracked like migrations.
3333

@@ -45,6 +45,8 @@ dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Server=localhost\
4545

4646
Or rely on [appsettings.Development.json](src/Api/appsettings.Development.json) for local SQL/JWT (dev only).
4747

48+
In Development, `Features:RequireEmailVerification` is `false` — newly created users can log in immediately without completing email verification. Set it to `true` (the production default) to test the OTP flow.
49+
4850
### 2. Run the API
4951

5052
```powershell
@@ -66,7 +68,7 @@ Open:
6668
- Health: `GET /api/v1/health`
6769
- API base: `/api/v1`
6870

69-
**Default SuperAdmin** (after seeds): `admin@system.com` / value of `Seeding:AdminPassword` (e.g. `Admin123!` in Development).
71+
**Default SystemAdmin** (after seeds): `admin@system.com` / value of `Seeding:AdminPassword` (e.g. `Admin123!` in Development).
7072

7173
### 3. Add a migration (developers)
7274

@@ -89,18 +91,24 @@ See [docs/DEPLOYMENT.md](docs/DEPLOYMENT.md) for production deploy.
8991

9092
- Deploy: push to **`master`** or run **Deploy to MonsterASP (FTPS)** workflow.
9193
- Required GitHub secrets: `FTP_*`, `PRODUCTION_CONNECTION_STRING`, `JWT_KEY`, `ADMIN_PASSWORD`, recommended `SITE_URL`.
94+
- Email verification is **on** by default in production (`Features:RequireEmailVerification: true`). New users must verify their email via OTP before logging in.
9295
- Swagger: `https://<your-site>/swagger` — open (set `Swagger:EnabledInProduction` to `false` to hide it).
9396
- Fresh database: delete and recreate the database in the MonsterASP control panel (or drop all tables in SSMS), then redeploy.
9497

9598
## Highlights
9699

97-
- **Permissions**: PascalCase (`Users.View`); checked per request, **not** in JWT
98-
- **JWT claims**: `user_id`, `tenant_id`, `role_id`, role names
100+
- **Hybrid RBAC**: Layer 1 = `SystemRole` on `ApplicationUser` (ceiling authority); Layer 2 = custom roles with permissions (TenantUser business capabilities only)
101+
- **Three system roles**: `SystemAdmin` (platform), `TenantAdmin` (manages one tenant), `TenantUser` (operational)
102+
- **X-Tenant-Id header**: SystemAdmin must supply `X-Tenant-Id` on all tenant-scoped requests; TenantAdmin/TenantUser are always pinned to their JWT `tenant_id`
103+
- **Email verification**: OTP-based (6-digit, 15 min); skipped in Development via `Features:RequireEmailVerification: false`
104+
- **Permissions**: PascalCase (`Users.View`); checked per request from DB (cached), never in JWT
105+
- **JWT claims**: `user_id`, `tenant_id`, `system_role`, `full_name`, `role_ids`
99106
- **Versioned seeds**: `SeedHistory` table; pending seeds only (like migrations)
100107
- **Profiles**: user & tenant profile images via `Files` FK; `profileUrl` in responses
101108
- **Addresses**: optional user/tenant address with `fullAddress` combined string
109+
- **Invitations**: TenantAdmin invites TenantUsers; SystemAdmin invites TenantAdmins
102110
- **Onboarding**: `POST /api/v1/tenants` with `user`, `tenant`, `roles[]` (permission GUIDs)
103-
- **No public registration**SuperAdmin onboards tenants
111+
- **No public registration**SystemAdmin onboards tenants
104112

105113
## Project structure
106114

Tempcookies_admin.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Netscape HTTP Cookie File
2+
# https://curl.se/docs/http-cookies.html
3+
# This file was generated by libcurl! Edit at your own risk.
4+
5+
#HttpOnly_localhost FALSE / FALSE 1782583388 refresh_token H9%2Brv5zORv6HZtv4SqyQ20A%2BCQ%2BEx3PUvVhvqzmnnnoUlkjD1WcPkwAg4SVPsqiTru2NJqO6DvpknOvYV%2BOOfg%3D%3D
6+
#HttpOnly_localhost FALSE / FALSE 1781979488 access_token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhOTA3OWIyYS1jZmJmLTQ1MzktYTRkOS1iYzliMTA3Zjg2ZTgiLCJlbWFpbCI6ImFkbWluQHN5c3RlbS5jb20iLCJqdGkiOiI1NmQ4ZmJmYS1hNjViLTQyYjQtOTFjOC04ZjBiMGRhNjM5OWUiLCJ1c2VyX2lkIjoiYTkwNzliMmEtY2ZiZi00NTM5LWE0ZDktYmM5YjEwN2Y4NmU4IiwidGVuYW50X2lkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIiwiZnVsbF9uYW1lIjoiU3lzdGVtIEFkbWluaXN0cmF0b3IiLCJzeXN0ZW1fcm9sZSI6IjEiLCJleHAiOjE3ODE5Nzk0ODgsImlzcyI6Ik11bHRpVGVuYW50UGxhdGZvcm0iLCJhdWQiOiJNdWx0aVRlbmFudFBsYXRmb3JtVXNlcnMifQ.dDcS6E4cUn8VsgYDVQb0yfYUEQBRLnYqEOyYVPvYmrE

0 commit comments

Comments
 (0)