Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (33)
📝 WalkthroughWalkthroughThe PR replaces LDAP, OIDC, and CAS authentication systems with WorkOS-based authentication via a new Changes
Sequence Diagram(s)sequenceDiagram
participant User as User Browser
participant Frontend as Frontend (SPA)
participant Backend as Backend API
participant WorkOS as WorkOS
participant DB as Database
User->>Frontend: Click "Continue with WorkOS"
Frontend->>Backend: GET /api/auth/workos/authorize/
Backend->>Backend: Generate state, create secure cookie
Backend->>WorkOS: Redirect to WorkOS consent screen
Backend-->>Frontend: 302 redirect to WorkOS
User->>WorkOS: Log in / authorize
WorkOS->>Backend: Redirect to /api/auth/workos/callback/?code=...&state=...
Backend->>Backend: Validate state cookie
Backend->>WorkOS: Exchange code for user info
WorkOS-->>Backend: Return user + access_token
Backend->>Backend: Decode JWT token for session_id
Backend->>DB: Query/provision user by email
Backend->>DB: Update workos_user_id, avatar_url
Backend->>DB: Assign groups & roles by email
Backend->>Backend: Store exchange code in Redis
Backend-->>Frontend: 302 redirect to /login/callback?code=...
User->>Frontend: Redirect received
Frontend->>Backend: POST /api/auth/workos/exchange/ with code
Backend->>Backend: Retrieve & validate exchange code from Redis
Backend->>DB: Load user record
Backend->>Backend: Issue local JWT pair (access + refresh)
Backend-->>Frontend: Return { access, refresh }
Frontend->>Frontend: Store tokens, load user profile
Frontend->>Backend: GET /api/v1/me/
Backend-->>Frontend: Return user + is_workos_managed, avatar_url
Frontend->>User: Display authenticated dashboard
sequenceDiagram
participant User as User Browser
participant Frontend as Frontend (SPA)
participant Backend as Backend API
participant WorkOS as WorkOS
User->>Frontend: Click Logout
Frontend->>Backend: GET /api/auth/workos/logout/
Backend->>Backend: Check if WorkOS session cookie present
alt Session cookie exists
Backend->>WorkOS: Get logout URL for session_id
WorkOS-->>Backend: Return logout URL
Backend-->>Frontend: 302 redirect to WorkOS logout URL
User->>WorkOS: Log out
WorkOS-->>Frontend: Redirect to /login
else No session cookie
Backend-->>Frontend: 302 redirect to /login
end
Frontend->>Frontend: Clear local tokens
User->>Frontend: Display login page
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
This PR adds a deployment-wide authentication switch so Datamingle can run in either local builtin auth mode or WorkOS mode.
What Changed
AUTH_MODE=builtin|workoswith WorkOS env validation and a dedicated WorkOS auth flowUsers.workos_user_idREADME.mdWhy
The enterprise deployment model now needs a clear choice between local Datamingle auth and WorkOS-backed tenant auth. The previous code still exposed legacy OIDC/LDAP/CAS paths that no longer fit that direction.
Impact
Validation
docker exec datamingle-app python manage.py test sql_api.test_workos_auth sql_api.tests.TestTokenAuth2FA sql.tests.TestUserdocker exec datamingle-app python manage.py makemigrations sql --checkcd frontend && npm run buildblack --check .Notes
Before running with
AUTH_MODE=workos, rebuild the app container so theworkosdependency fromrequirements.txtis installed.Summary by CodeRabbit
New Features
Removed Features
Bug Fixes & Updates