Skip to content

[JENKINS-64991] Login redirect to previous page no longer works #11939

Closed

Description

@jenkins-infra-bot

When logging in, the "from" URL is no longer being redirected to.

  1. docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:2.265
  2. Pass the setup wizard not installing anything, keep admin user.
  3. In /configureSecurity, allow anonymous read access
  4. As anonymous, go to http://localhost:8080/view/all/builds
  5. Click log in
  6. Log in as admin

Expected result (up to 2.265): Back to Build History

Actual result (from 2.266): Index page

This is a regression, probably caused by

/* TODO none of this compiles against Spring Security; rewrite (try InteractiveAuthenticationSuccessEvent & SimpleUrlAuthenticationFailureHandler):
@Override
protected String determineTargetUrl(HttpServletRequest request) {
AbstractAuthenticationProcessingFilter f = new UsernamePasswordAuthenticationFilter();
String targetUrl = request.getParameter("from");
request.getSession().setAttribute("from", targetUrl);
if (targetUrl == null)
return getDefaultTargetUrl();
if (!Util.isSafeToRedirectTo(targetUrl))
return "."; // avoid open redirect
// URL returned from determineTargetUrl() is resolved against the context path,
// whereas the "from" URL is resolved against the top of the website, so adjust this.
if(targetUrl.startsWith(request.getContextPath()))
return targetUrl.substring(request.getContextPath().length());
// not sure when this happens, but apparently this happens in some case.
// see #1274
return targetUrl;
}
/**
* @see AbstractProcessingFilter#determineFailureUrl(HttpServletRequest, AuthenticationException)
* /
@Override
protected String determineFailureUrl(HttpServletRequest request, AuthenticationException failed) {
Properties excMap = getExceptionMappings();
String failedClassName = failed.getClass().getName();
String whereFrom = request.getParameter("from");
request.getSession().setAttribute("from", whereFrom);
return excMap.getProperty(failedClassName, getAuthenticationFailureUrl());
}
*/


Originally reported by danielbeck, imported from: Login redirect to previous page no longer works
  • assignee: danielbeck
  • status: Closed
  • priority: Minor
  • component(s): core
  • label(s): 2.289.2-fixed, JEP-227, ci.jenkins.io-ux, regression, ux
  • resolution: Fixed
  • resolved: 2021-05-25T20:34:41+00:00
  • votes: 1
  • watchers: 7
  • imported: 2025-11-24
Raw content of original issue

When logging in, the "from" URL is no longer being redirected to.

  1. docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:2.265
  2. Pass the setup wizard not installing anything, keep admin user.
  3. In /configureSecurity, allow anonymous read access
  4. As anonymous, go to http://localhost:8080/view/all/builds
  5. Click log in
  6. Log in as admin

Expected result (up to 2.265): Back to Build History

Actual result (from 2.266): Index page

This is a regression, probably caused by

/* TODO none of this compiles against Spring Security; rewrite (try InteractiveAuthenticationSuccessEvent & SimpleUrlAuthenticationFailureHandler):
@Override
protected String determineTargetUrl(HttpServletRequest request) {
AbstractAuthenticationProcessingFilter f = new UsernamePasswordAuthenticationFilter();
String targetUrl = request.getParameter("from");
request.getSession().setAttribute("from", targetUrl);
if (targetUrl == null)
return getDefaultTargetUrl();
if (!Util.isSafeToRedirectTo(targetUrl))
return "."; // avoid open redirect
// URL returned from determineTargetUrl() is resolved against the context path,
// whereas the "from" URL is resolved against the top of the website, so adjust this.
if(targetUrl.startsWith(request.getContextPath()))
return targetUrl.substring(request.getContextPath().length());
// not sure when this happens, but apparently this happens in some case.
// see #1274
return targetUrl;
}
/**
* @see AbstractProcessingFilter#determineFailureUrl(HttpServletRequest, AuthenticationException)
* /
@Override
protected String determineFailureUrl(HttpServletRequest request, AuthenticationException failed) {
Properties excMap = getExceptionMappings();
String failedClassName = failed.getClass().getName();
String whereFrom = request.getParameter("from");
request.getSession().setAttribute("from", whereFrom);
return excMap.getProperty(failedClassName, getAuthenticationFailureUrl());
}
*/

Activity

  1. jenkins-infra-bot commented on Mar 2, 2021

    @jenkins-infra-bot
    Author
  2. jenkins-infra-bot commented on Mar 2, 2021

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      Thought I had checked this scenario, but evidently not. As you can see, test coverage in this area was pretty weak.

    Thought I had checked this scenario, but evidently not. As you can see, test coverage in this area was pretty weak.

  3. jenkins-infra-bot commented on Mar 2, 2021

    @jenkins-infra-bot
    Author
    danielbeck:
    • Original comment link
    • Raw content of original comment:

      jglick I think there's a difference between this as described, and the redirect from an Unauthorized response. I think the latter still works.

    jglick I think there's a difference between this as described, and the redirect from an Unauthorized response. I think the latter still works.

  4. jenkins-infra-bot commented on Mar 2, 2021

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      I see, this is about a page on which you had a 200 status but decided to log in anyway.

    I see, this is about a page on which you had a 200 status but decided to log in anyway.

  5. jenkins-infra-bot commented on Mar 2, 2021

    @jenkins-infra-bot
    Author
    danielbeck:
    • Original comment link
    • Raw content of original comment:

      Yes, step 3 in the reproduction is important. Without it (and consequently without step 5, you just get redirected to the login form), the redirect still works in 2.266.

    Yes, step 3 in the reproduction is important. Without it (and consequently without step 5, you just get redirected to the login form), the redirect still works in 2.266.

  6. jenkins-infra-bot commented on Mar 11, 2021

    @jenkins-infra-bot
    Author
    danielbeck:
    • Original comment link
    • Raw content of original comment:

      ci.jenkins.io was updated to 2.277.1 and it's incredibly annoying. I'm not triggering PR builds through that UI anymore.

      1. Click on a PR status
      2. Go to the build info
      3. Click Blue Ocean login link
      4. Log in
      5. Get forwarded to home page

    ci.jenkins.io was updated to 2.277.1 and it's incredibly annoying. I'm not triggering PR builds through that UI anymore.

    1. Click on a PR status
    2. Go to the build info
    3. Click Blue Ocean login link
    4. Log in
    5. Get forwarded to home page
  7. jenkins-infra-bot commented on Mar 11, 2021

    @jenkins-infra-bot
    Author
    timja:
    • Original comment link
    • Raw content of original comment:

      clicking re-run from the checks page is probably quicker than that anyway

    clicking re-run from the checks page is probably quicker than that anyway

  8. jenkins-infra-bot commented on Mar 14, 2021

    @jenkins-infra-bot
    Author
    danielbeck:
    • Original comment link
    • Raw content of original comment:

      clicking re-run from the checks page is probably quicker than that anyway

      Not possible in jenkins-infra/update-center2

    clicking re-run from the checks page is probably quicker than that anyway

    Not possible in jenkins-infra/update-center2

  9. jenkins-infra-bot commented on May 4, 2021

    @jenkins-infra-bot
    Author
    basil:
    • Original comment link
    • Raw content of original comment:

      One of my users reported this issue after we upgraded from 2.263.4 to 2.277.3.

    One of my users reported this issue after we upgraded from 2.263.4 to 2.277.3.

  10. jenkins-infra-bot commented on May 5, 2021

    @jenkins-infra-bot
    Author
    danielbeck:

    #5461 as a start, unsure whether I'll find the time to finish in the next few weeks though.

  11. jenkins-infra-bot commented on May 27, 2021

    @jenkins-infra-bot
    Author
    nkadelgarcia:
    • Original comment link
    • Raw content of original comment:

      It's particularly irksome if you allow anonymous browsing to review the status of your jobs, and need to log in to do a build or update an option.

    It's particularly irksome if you allow anonymous browsing to review the status of your jobs, and need to log in to do a build or update an option.

  12. jenkins-infra-bot commented on May 27, 2021

    @jenkins-infra-bot
    Author
    timja:
    • Original comment link
    • Raw content of original comment:

      The fix is merged and will be released next week

    The fix is merged and will be released next week

  13. jenkins-infra-bot commented on Nov 24, 2025

    @jenkins-infra-bot
    Author

    [Original relates_to from Jira: JENKINS-66026]

  14. jenkins-infra-bot commented on Nov 24, 2025

    @jenkins-infra-bot
    Author

    [Original relates_to from Jira: JENKINS-65452]

  15. removed
    bugFor changelog: Minor bug. Will be listed after features
    on Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions