Uploaded image for project: 'RH-SSO'
  1. RH-SSO
  2. RHSSO-818

Reset password leads to 400 bad request when link is opened in a different browser session

XMLWordPrintable

    • Hide

      1. Enable reset password
      2. Access an application using Keycloak OIDC adapter
      3. Click on reset password
      4. Open link in a new browser session
      5. Reset password
      6. You'll now see a 400 bad request as the state cookie is missing

      Note that you need to clear cookies before step 4 (just in case), and an application need to be deployed another EAP instance than RH-SSO.

      Show
      1. Enable reset password 2. Access an application using Keycloak OIDC adapter 3. Click on reset password 4. Open link in a new browser session 5. Reset password 6. You'll now see a 400 bad request as the state cookie is missing Note that you need to clear cookies before step 4 (just in case), and an application need to be deployed another EAP instance than RH-SSO.

      The adapter throws a 400 bad request after a reset password link has been opened in a new browser session due to the session cookie is missing. This issue is down to the fact that the reset password flow redirects to the application with the authorization code even though it should detect that there's a new browser session and instead display a message "Your password has been updated" and have a link "back to application" like verify email does.

      This is similar to https://issues.jboss.org/browse/KEYCLOAK-3331 , but the PR provided there does not resolve the issue.

      In RH-SSO 7.0.0, the error status is generated at the line #221 in org.keycloak.adapters.OAuthRequestAuthenticator. But the upstream Keycloak (3.0.0.CRx) does not use it when resetting password.

      [hokuda@dhcp-193-78 01795818_rhsso_reset_password_400]$ /home/hokuda/src/github.com/hokuda/rljdb/rljdb -attach localhost:18787   [6/541]
      Set uncaught java.lang.Throwable
      Set deferred uncaught java.lang.Throwable
      Initializing jdb ...
      Found ./rljdb.breakpoint
      > 
      Breakpoint hit: "thread=http-127.0.0.1:8180-1", org.keycloak.adapters.OAuthRequestAuthenticator.checkStateCookie(), line=221 bci=24
      221                return challenge(400, OIDCAuthenticationError.Reason.INVALID_STATE_COOKIE, null);
      
      http-127.0.0.1:8180-1[1] list
      217            OIDCHttpFacade.Cookie stateCookie = getCookie(deployment.getStateCookieName());
      218    
      219            if (stateCookie == null) {
      220                log.warn("No state cookie");
      221 =>             return challenge(400, OIDCAuthenticationError.Reason.INVALID_STATE_COOKIE, null);
      222            }
      223            // reset the cookie
      224            log.debug("** reseting application state cookie");
      225            facade.getResponse().resetCookie(deployment.getStateCookieName(), stateCookie.getPath());
      226            String stateCookieValue = getCookieValue(deployment.getStateCookieName());
      http-127.0.0.1:8180-1[1] 
      

            Unassigned Unassigned
            rhn-support-hokuda Hisanobu Okuda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: