Repository navigation
CLARIN-DSpace v9/Derive the temporary auth cookie path from dspace.server.url - #1490
Open
milanmajchrak wants to merge 4 commits into
Open
milanmajchrak wants to merge 4 commits into
milanmajchrak wants to merge 4 commits into
Conversation
The cookie was always issued with Path=/server/api/authn, so under another context path (e.g. /repository/server) the browser never sent it to /api/authn/login and the Shibboleth/OIDC/ORCID/SAML login ended as anonymous. The removal cookie now carries the same path. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Upstream already has an open PR for this bug: DSpace#11753. It derives the cookie path from We opened a PR against the author's branch with the parts of this PR that fit that design: an integration test that fails without the fix, and the same
Upstream duplicates (all open, no review): |
The login callbacks and the UI use dspace.server.url, so the cookie path follows it also when the servlet context path is different, e.g. behind a proxy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
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
No dtq-dev source: 7.x (
origin/dtq-dev) sets no path on this cookie, so the bug is 9-base only. Vanilla has the same hardcoded path on dspace-9.3 and main (commit 551eed8, "Add SAML login filter"); upstream candidate.Found on a v9 test instance where the REST API runs under
/repository/server.Description
The temporary
Authorization-cookieused by the Shibboleth, OIDC, ORCID and SAML login was always issued withPath=/server/api/authn, so under another context path the browser never sends it to/api/authn/loginand the external login ends as anonymous. The path now comes fromdspace.server.url, for the cookie and for its removal.Instructions for Reviewers
List of changes in this PR:
JWTTokenRestAuthenticationServiceImpl: newgetAuthorizationCookiePath()returns the path ofdspace.server.url(raw, without a trailing slash) plus/api/authn.addTokenToResponseuses it instead of the constant, andinvalidateAuthenticationCookienow sets the same path (it had none, so the browser could keep the old cookie). The login callbacks build their URLs from the same property, so it also works behind a proxy that strips the prefix.AuthenticationRestControllerIT: newtestShibAuthCookiePathFollowsServerUrlruns the Shibboleth flow fordspace.server.urlending in/server,/server/,/repository/serverand/caf%C3%A9/server, also with a servlet context path other than the public one, and checks the path on the issued cookie and on the one/loginsends back to remove it.testStatusShibAuthenticatedWithCookienow also checksPath=/api/authnfor the testdspace.server.url(http://localhost).How to test:
AuthenticationRestControllerIT. The new test fails on the old code (Path=/server/api/authn)./repository/server) with an external IdP, log in with Shibboleth or ORCID and watch the network tab: the redirect back from the provider setsAuthorization-cookiewithPath=/repository/server/api/authn, and the followingPOST /api/authn/loginanswers 200 with anAuthorizationheader. Before the fix the cookie path was/server/api/authn, the browser did not send it, and the user stayed anonymous. Plain HTTP cannot show this: the cookie isSecure; SameSite=None./servercontext behaves as before:Path=/server/api/authn.Codex review (gpt-6.2-sol, high), 3 rounds: 3 findings fixed (path from
dspace.server.urlinstead of the servlet context, trailing slash, percent escapes kept). The last round found 2, not changed in this PR: a literal non-ASCII character or a../segment written intodspace.server.url.Checklist
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.🤖 Generated with Claude Code