Repository navigation
[dtq-dev-93] Return to the right page after login (DiscoJuice local and Shibboleth, expired session) - #1764
Open
milanmajchrak wants to merge 10 commits into
Open
[dtq-dev-93] Return to the right page after login (DiscoJuice local and Shibboleth, expired session)#1764milanmajchrak wants to merge 10 commits into
milanmajchrak wants to merge 10 commits into
Conversation
The login page puts the stored post-login target into ?redirectUrl=, so aai.js keeps it through the local-login reload and in the Shibboleth target. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A password login started on the login page itself now ends on the home page, as in 7.x, instead of on the already-logged-in message. Co-Authored-By: Claude Opus 5.5 <[email protected]>
aai.js now encodes the return URL it puts into /login?redirectUrl=, so a query string like ?configuration=workflow or a second param survives the reload. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The hard redirect used /login?expired=true, which drops the base href and gives a 404 when the UI runs under a sub-path like /repository/. Co-Authored-By: Claude Opus 5.5 <[email protected]>
After local login the login page has a full URL in redirectUrl. aai.js put the namespace in front of it, so Shibboleth returned to a broken URL. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Location.normalize turns the home page URL into an empty string, so a stored page won over it. An empty path now means /. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The server answered with a 302 to /login?expired=true, which the browser resolves from the host root, not from the base href. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Only the inner redirectUrl was encoded, so a return page like /search?query=corpus&page=2 reached the backend without page=2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A request-a-copy return URL with accessToken stays in the store only; the password login on the login page still returns to it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
References
Ports this dtq-dev PR:
Description
After local or Shibboleth login through DiscoJuice, the user lands on the protected page that sent them to login. A local login started on
/loginitself ends on the home page, and an expired session opens the login page under the base href.Instructions for Reviewers
List of changes in this PR:
LoginPageComponentputs the stored post-login URL (set by the auth guard) into the URL, e.g./login?redirectUrl=%2Fmydspace. It does this only in the browser, only when the URL has noredirectUrlyet, and it replaces the history entry. A stored URL with a request-a-copyaccessTokenis not copied there; it stays in the store, and the password login on/loginstill returns to it.aai.jstakes the return page only from the URL, so before, local and Shibboleth login both returned to/loginitself. The v9 port had only the read side inLogInPasswordComponent.submit(); on 7.6 this part lived inLogInPasswordComponent.setUpRedirectUrl().LogInPasswordComponentalso strips the base href fromredirectUrl(Location.normalize, empty path =/). A login started on/loginnow targets/login, andAuthService.navigateToRedirectUrlalready sends that home. Before, the user ended on "You're Already Logged In".aai.jslocal login encodes the page URL it puts into/login?redirectUrl=. So the page's query string survives, e.g./mydspace?configuration=workflow.aai.jsShibboleth login keeps a full URL of this site fromredirectUrl(local login puts one there). Before, it put the namespace in front of it. Anything else is still taken as a path in the app.aai.jsShibboleth login encodes the whole backendtarget, not only theredirectUrlinside it. So/search?query=corpus&page=2reaches the backend withpage=2. Simple return URLs reach the backend unchanged.AuthService.redirectToLoginWhenTokenExpired()goes to./login?expired=true, relative to<base href>like thereload/URL. Before,/login?expired=truewas a 404 under/repository/. The SSR override inServerAuthServiceaddsui.nameSpaceto its 302 for the same reason.angular.jsonno longer copiessrc/aai/*.spec.tsinto the build.src/aai/aai.spec.tstests three small aai.js helpers, exposed onwindow.aaifor that.How to test (UI under
/repository/):<ui>/mydspace. You land on/login?redirectUrl=%2Fmydspace./mydspace./mydspaceagain and pick your IdP in DiscoJuice. After the IdP you land on/mydspace. Under/repository/this also needs the backend auth cookie path fix (backend PR 1490).<ui>/logindirectly, pick "Local authentication" and log in. You land on the home page.<ui>/mydspace?configuration=workflowand log in with "Local authentication". You land on the same URL.npm run test -- --include=<spec>forsrc/aai/aai.spec.ts,src/app/login-page/login-page.component.spec.ts,src/app/shared/log-in/methods/password/log-in-password.component.spec.ts,src/app/core/auth/auth.service.spec.tsandsrc/app/core/auth/server-auth.service.spec.ts.Codex review (gpt-6.2-sol, high), 2 rounds: 2 findings fixed (the Shibboleth
targetwas not encoded as a whole, a stored URL with anaccessTokenwent into the login URL). Not changed in this PR:ui.nameSpaceequals a route prefix, e.g./items, a return to/items/items/123loses one/items.share_tokenstill goes into the login URL, as on 7.x.accessToken, the DiscoJuice "Local authentication" login ends on the home page.Checklist
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.🤖 Generated with Claude Code