Use client-side redirects in admin monitors for Chrome #26207
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.
Fixes #26001
I considered multiple options to address this issue:
www.jenkins.io, so that would be easy.Locationheader to client-side JS/metatag.The first one is easy but limited: Any URLs outside www.jenkins.io would be unsupported. Even if there aren't many problems like this across plugins, relaxing rules does not set a good example for plugin developers.
The second one was my favorite until I found #26205. It's still my favorite option for plugins though, and has as additional benefit that it's straightforward to open the link in a new window.
The third seems unnecessarily complicated on the view, so I dismissed it quickly.
This implementation uses the fourth option. For use in plugins, they would need to increase the core dependency, or reimplement the
HttpResponsecallingUtil#printRedirectthemselves. The latter seems reasonable, with just using a (currently broken looking) link probably the easiest.FWIW there is currently no caller for
HttpResponses#clientRedirectTo, so technically not ideal. It seems like a natural addition to that API though, and mirrors existing methods. Adding it there would help discoverability.In terms of plugins, a quick GH code search found just:
Even if my search is not complete, I would expect this to be a problem in few plugins, and it's fairly easily resolved with a link.
Testing done
Clicked the buttons in Chrome once the monitors showed:
jetty:run, since it fails with "HTTP ERROR 400 Ambiguous URI path separator".hudson.security.csrf.DefaultCrumbIssuer.EXCLUDE_SESSION_ID = truein script consoleJavaVersionRecommendationAdminMonitorso it's already due.I skipped autotests, because the new code is just a minor adapter around existing code doing the actual work.
Screenshots (UI changes only)
n/a
Before
After
Proposed changelog entries
Proposed changelog category
/label bug
Proposed upgrade guidelines
N/A
Submitter checklist
@Restrictedor have@since TODOJavadocs, as appropriate.@Deprecated(since = "TODO")or@Deprecated(forRemoval = true, since = "TODO"), if applicable.evalto ease future introduction of Content Security Policy (CSP) directives (see documentation).Desired reviewers
@mention
Before the changes are marked as
ready-for-merge:Maintainer checklist
upgrade-guide-neededlabel is set and there is a Proposed upgrade guidelines section in the pull request title (see example).lts-candidateto be considered.