feat: implement transactional OAuth onboarding and role provisioning - #127
Open
Yasir-TechGuy wants to merge 1 commit into
Open
feat: implement transactional OAuth onboarding and role provisioning#127Yasir-TechGuy wants to merge 1 commit into
Yasir-TechGuy wants to merge 1 commit into
Conversation
- Add onboarding state schema with state machine (pending, role_selected, provisioned, failed, disabled) - Implement idempotent identity creation with OAuth provider linking - Add atomic role provisioning with MongoDB transaction support - Create unified bootstrap endpoint replacing scattered client init checks - Add role selection API endpoint for frontend integration - Add integration tests covering: callback retry, concurrent selection, disabled user, provider linking - Add documentation for onboarding state machine and recovery procedures Closes Eduvault-stellar#91
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feat: Transactional OAuth Onboarding and Role Provisioning
What This PR Does
This PR fixes the OAuth onboarding and role provisioning system to be transactionally consistent. It ensures users never reach the dashboard with an incomplete role state.
What Was The Problem?
How This Fixes It
1. Onboarding State Machine
Tracks where the user is in the onboarding flow:
2. Idempotent Identity Creation
3. Atomic Role Provisioning
4. Unified Bootstrap Endpoint
5. Integration Tests
Covering: callback retry, concurrent selection, disabled user, and provider linking
Files Created
src/lib/db/schemas/onboarding.js- State schemasrc/lib/auth/identityService.js- Identity creationsrc/lib/auth/roleProvisioning.js- Role provisioningsrc/app/api/auth/bootstrap/route.js- Bootstrap endpointsrc/app/api/auth/onboarding/role/route.js- Role selection APItest/integration/onboarding/role-provisioning.test.js- Testsdocs/onboarding-state-machine.md- DocumentationAPI Endpoints
GET /api/auth/bootstrap - Get user state
POST /api/auth/onboarding/role - Select and provision role
Testing
npm test -- test/integration/onboarding/role-provisioning.test.js
Acceptance Criteria Checklist
Closes
Closes #91