Show dedicated sign-in blocked page for linked-primary account HTTP 409#253
Open
Gerry-Cern wants to merge 5 commits into
Open
Show dedicated sign-in blocked page for linked-primary account HTTP 409#253Gerry-Cern wants to merge 5 commits into
Gerry-Cern wants to merge 5 commits into
Conversation
- Updated AuthService to manage linked primary account errors, redirecting to a new 'linkedAccountBlocked' page. - Introduced a new helper for linked primary account error detection and handling. - Enhanced error handling in the HttpClient and ClientService to support linked account scenarios. - Added a new Vue component for the linked account blocked page with appropriate routing. - Updated tests to cover new functionality and ensure proper error handling.
…ount blocked page - Updated linked primary account error detection to include trusted signals for protected endpoints. - Improved error handling logic in `isLinkedPrimaryAccountError` function. - Added default documentation and portal URLs in the linked account blocked page component. - Enhanced unit tests to cover new scenarios for linked primary account errors and default link rendering.
- Introduced a new `createLinkedPrimaryRejectionHandler` function to streamline error handling for linked-primary account errors. - Updated `attachLinkedPrimaryAccountResponseInterceptor` to utilize the new handler, improving code clarity and maintainability. - Enhanced unit tests to validate the new rejection handler functionality and ensure proper error handling behavior.
- Replaced the "Log in again" button with a "Log out" button that triggers the logout process. - Updated the component to remove unused imports and streamline the code. - Enhanced unit tests to verify the logout functionality and ensure proper interaction with the auth service.
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.
Summary
When a user signs in with an identity that CERNBox blocks as a linked primary account, the backend returns HTTP 409 with a machine-readable linked-primary contract (Reva
http.interceptors.auth, documented asidentity-auth-http-errors). Previously, Web treated that like a generic auth failure and sent users to Access denied.This PR detects that contract on Graph, OCS, and authenticated HTTP responses, routes auth errors to a new
linkedAccountBlockedpage, and surfaces configurable links to documentation and the user portal where the account can be unlinked.Companion change (separate repo): cs3org/reva branch
feat/4348-linked-primary-http-contractadds the HTTP response shape (409,X-Oc-Linked-Primary-Account: true, JSONerror.code: linkedPrimaryAccount). Detection in production also depends on cernbox/reva-plugins (v0.0.37+, “block linked accounts”) via the REST user provider.Problem
useRevaTokenand multiple HTTP stacks (Graph, OCS, authenticated HTTP); handling must be centralized.Solution
Backend contract (consumer)
Web treats a response as linked-primary when:
409 ConflictX-Oc-Linked-Primary-Account: trueerror.codeinlinkedPrimaryAccount(and documented aliases)error.messagecontains “linked primary account”Bootstrap paths include Graph
/me, OCS user/capabilities, and settings URLs (seeisIdentityBootstrapRequestUrl).Web changes
linkedPrimaryAccountError.ts— Shared detection,createLinkedPrimaryRejectionHandler, Axios interceptor helper, and a marker to avoid duplicatehandleAuthError/removeUsercalls.ClientService.attachLinkedPrimaryAccountHandling— Registers handlers on Graph, OCS, and authenticated HTTP clients at bootstrap.AuthService— SetsauthBlockRouteNametolinkedAccountBlockedwhen the error cause matches; auth guard keeps users on that route instead of login.linkedAccountBlocked.vue— Dedicated page (same layout pattern as access denied) with:https://auth.docs.cern.ch/user-documentation/verified-guest/)https://account.cern.ch/account/, oroptions.accountEditLink.href)options.linkedAccount.docUrlandoptions.linkedAccount.userPortalUrlinOptionsConfigSchema.What we intentionally do not match
Files changed
packages/web-pkg/src/helpers/auth/linkedPrimaryAccountError.ts,client.ts,http/client.tsauthService.ts,bootstrap.ts,setupAuthGuard.ts,useAuthService.tslinkedAccountBlocked.vue,router/index.tsconfig/types.tslinkedPrimaryAccountError.spec.ts,linkedAccountBlocked.spec.ts,authService.spec.ts, snapshotTest plan
Automated
npx vitest run linkedPrimaryAccountError linkedAccountBlocked authService.spec(33 tests)Manual (requires backend with full stack)
Deploy or point Web at a backend with:
reva-plugins≥ v0.0.37 (linked-account block on@cern.chusername lookup)useRevaTokenif applicable)GET .../graph/v1.0/meor OCS user)X-Oc-Linked-Primary-Account: true, bodyerror.code: linkedPrimaryAccount/linked-account-blocked(not access denied): title “Sign-in blocked”, doc + portal links, “Log in again”options.linkedAccountinconfig.jsonRegression
Deployment notes
feat/4348-linked-primary-http-contract) inrevadbefore or with this Web change; otherwise Web cannot detect the contract reliably.reva-pluginsis already required in CERNrevadbuilds; no Web change needed there.options.linkedAccounttoweb.jsonif defaults should differ per environment (defaults are CERN URLs in the Vue component).Related
feat/4348-linked-primary-http-contract