@@ -42,6 +42,7 @@ The OAuth implementation includes:
4242- ** OAuth Discovery Service** - Detects OAuth requirement and discovers endpoints using RFC 8414/9728
4343- ** Authorization Endpoint** - Initiates OAuth flow with PKCE, state parameter, and resource parameter
4444- ** Callback Endpoint** - Exchanges authorization code for tokens
45+ - ** Re-Authentication Endpoint** - User-initiated token refresh when automatic refresh fails
4546- ** Token Service** - Handles token exchange and refresh operations
4647- ** Client Registration Service** - Implements RFC 7591 Dynamic Client Registration (DCR)
4748- ** Encryption Service** - AES-256-GCM encryption for tokens at rest
@@ -837,16 +838,43 @@ INFO: OAuth token refresh job completed (totalTokens: 3, successCount: 3, failur
837838
838839### Token Expiration Handling
839840
840- ** During token refresh cron job** :
841+ When automatic token refresh fails (server offline, invalid refresh token, token revoked), the installation enters ` requires_reauth ` status. Users can recover through self-service re-authentication.
842+
843+ ** Automatic Refresh Failure** :
844+ - Token refresh job attempts refresh
845+ - Refresh fails (network error, invalid_grant, server offline)
841846- Installation status → ` requires_reauth `
842- - User sees "Reconnect" button in frontend
843- - User must re-authorize to get new tokens
844-
845- ** During satellite token retrieval** :
846- - Satellite checks ` expires_at ` timestamp
847- - If expired and no refresh possible → Return error to MCP client
848- - MCP client receives authentication error
849- - User must re-authenticate
847+ - Status message explains why re-auth is needed
848+
849+ ** User-Initiated Re-Authentication** :
850+
851+ Users can re-authenticate existing installations without reinstalling:
852+
853+ ** Endpoint** : ` POST /api/teams/:teamId/mcp/installations/:installationId/reauth `
854+
855+ ** Permission** : ` mcp.installations.view ` (both team_admin and team_user)
856+
857+ ** Why Both Roles** : OAuth tokens are per-user credentials, not team-level configuration. Each user authenticates with their own account.
858+
859+ ** Flow** :
860+ 1 . Frontend detects ` requires_reauth ` status and shows "Re-authenticate" button
861+ 2 . User clicks button → Backend starts OAuth flow (same as initial authorization)
862+ 3 . OAuth provider redirects to authorization page
863+ 4 . User authorizes → Callback exchanges code for new tokens
864+ 5 . Backend ** updates** existing token record (doesn't create new installation)
865+ 6 . Installation status → ` connecting ` → ` online `
866+ 7 . Satellite receives updated tokens via configuration sync
867+
868+ ** Key Difference from Initial Authorization** :
869+ - Initial: Creates new installation + new token record
870+ - Re-auth: Updates existing installation + existing token record
871+
872+ ** Database Impact** :
873+ - Pending flow created with ` installation_id ` reference (links to existing installation)
874+ - Callback detects ` installation_id ` and performs UPDATE instead of INSERT
875+ - Preserves team configuration (env vars, args, headers)
876+
877+ ** Security** : Same PKCE flow, state validation, and token encryption as initial authorization
850878
851879### Token Revocation
852880
0 commit comments