Overview
Implement the multi-tenant profile and branding architecture as outlined in auth-server/docs/proposals/001-multi-tenant-profile-branding.md.
This transforms the auth server from a RoboLearn-specific service into a production-ready multi-tenant identity platform with:
- OIDC-compliant user profiles
- Dynamic branding per OAuth client
- Clerk-style profile management UI
- Up to 3 tenant-defined custom fields per organization
Prerequisites (Must Complete First)
Before starting this implementation, complete all documentation issues:
Rationale: Documentation clarifies current architecture before major refactoring.
Implementation Phases
Phase 1: Schema Migration
Phase 2: Profile System Update
Phase 3: Dynamic Branding
Phase 4: Tenant Custom Fields
Phase 5: Cross-Tenant Flows
Phase 6: Cleanup & Migration
Success Criteria
Testing Requirements
Unit Tests:
- OIDC claims correctly populated in userinfo
- Custom fields saved to member.metadata
- Branding lookup returns correct data
- Cross-tenant membership flow works
Integration Tests:
- Full OAuth flow with new userinfo structure
- Dynamic branding renders correctly
- Custom field collection during sign-up
- Existing user joining new tenant
Visual Tests:
- Branded sign-in page renders correctly
- Custom field forms display properly during sign-up
- Profile management page works
- OIDC standard claims editable
- Custom fields dynamically render per organization
- Organization switcher works for multi-org users
- Phone verification flow works
- Form validation displays errors correctly
Related Issues
Closes:
Depends On:
Supersedes:
Documentation
Full proposal: auth-server/docs/proposals/001-multi-tenant-profile-branding.md
Key References:
- OIDC Standard Claims: OpenID Connect Core 1.0, Section 5.1
- Better Auth additionalFields: https://www.better-auth.com/docs
- Industry Patterns: Clerk, Auth0, Keycloak profile management
Estimated Effort
- Phase 1 (Schema): 2-3 hours
- Phase 2 (Profile UI): 8-10 hours
- Phase 3 (Branding): 4-6 hours
- Phase 4 (Custom Fields): 6-8 hours
- Phase 5 (Cross-Tenant): 4-6 hours
- Phase 6 (Cleanup): 2-3 hours
Total: ~26-36 hours (3-5 days of focused work)
Implementation Approach
Recommended: Use /sp.orchestrate with proposal document as input for structured SDD-RI workflow:
- Create feature branch:
feature/multi-tenant-profile-branding
- Run
/sp.orchestrate to generate spec.md, plan.md, tasks.md
- Execute phases incrementally with tests at each step
- Create PR when all success criteria met
Overview
Implement the multi-tenant profile and branding architecture as outlined in
auth-server/docs/proposals/001-multi-tenant-profile-branding.md.This transforms the auth server from a RoboLearn-specific service into a production-ready multi-tenant identity platform with:
Prerequisites (Must Complete First)
Before starting this implementation, complete all documentation issues:
Rationale: Documentation clarifies current architecture before major refactoring.
Implementation Phases
Phase 1: Schema Migration
usertableoauth2_clienttablecustom_fieldsJSONB toorganizationtablemetadataJSONB tomembertableuser_profiletable temporarily)Phase 2: Profile System Update
additionalFieldsfor OIDC claims/account/profilepage with standard claims formGET/PATCH /api/account/profileGET/PATCH /api/account/member-profilePhase 3: Dynamic Branding
GET /api/branding?client_id=xxx)Phase 4: Tenant Custom Fields
tenant_profileto userinfo responsePhase 5: Cross-Tenant Flows
Phase 6: Cleanup & Migration
user_profiledata tomember.metadatauser_profiletableSuccess Criteria
/account/profilefunctionalTesting Requirements
Unit Tests:
Integration Tests:
Visual Tests:
Related Issues
Closes:
Depends On:
Supersedes:
Documentation
Full proposal:
auth-server/docs/proposals/001-multi-tenant-profile-branding.mdKey References:
Estimated Effort
Total: ~26-36 hours (3-5 days of focused work)
Implementation Approach
Recommended: Use
/sp.orchestratewith proposal document as input for structured SDD-RI workflow:feature/multi-tenant-profile-branding/sp.orchestrateto generate spec.md, plan.md, tasks.md