You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2023/07/04 09:31:18 UTC

[sling-whiteboard] 01/05: oidc-rp: unregister the state from the state manager only when we're done with it

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit 387a0f64a14f64a6e002361894e45310d0a94de1
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Jul 4 12:14:51 2023 +0300

    oidc-rp: unregister the state from the state manager only when we're done with it
---
 .../org/apache/sling/servlets/oidc_rp/impl/OidcCallbackServlet.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/org.apache.sling.servlets.oidc-rp/src/main/java/org/apache/sling/servlets/oidc_rp/impl/OidcCallbackServlet.java b/org.apache.sling.servlets.oidc-rp/src/main/java/org/apache/sling/servlets/oidc_rp/impl/OidcCallbackServlet.java
index 341831fc..1508c041 100644
--- a/org.apache.sling.servlets.oidc-rp/src/main/java/org/apache/sling/servlets/oidc_rp/impl/OidcCallbackServlet.java
+++ b/org.apache.sling.servlets.oidc-rp/src/main/java/org/apache/sling/servlets/oidc_rp/impl/OidcCallbackServlet.java
@@ -104,11 +104,11 @@ public class OidcCallbackServlet extends SlingAllMethodsServlet {
                 throw new ServletException(authResponse.toErrorResponse().getErrorObject().toString());
 
             Optional<String> redirect = stateManager.getStateAttribute(authResponse.getState(), OidcStateManager.PARAMETER_NAME_REDIRECT);
-            stateManager.unregisterState(authResponse.getState());
             
             String authCode = authResponse.toSuccessResponse().getAuthorizationCode().getValue();
             
             Optional<String> desiredConnectionName = stateManager.getStateAttribute(authResponse.getState(), OidcStateManager.PARAMETER_NAME_CONNECTION);
+            stateManager.unregisterState(authResponse.getState());
             if ( desiredConnectionName.isEmpty() ) {
                 logger.debug("Did not find any connection in stateManager");
                 response.sendError(HttpServletResponse.SC_BAD_REQUEST);