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

markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 8d49ddc3c6 As per JASPIC specification, failure in secureResponse() 
should mean 500
8d49ddc3c6 is described below

commit 8d49ddc3c6d1f6e724dfa69d85fcf42b64046382
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Oct 26 15:07:39 2026 +0000

    As per JASPIC specification, failure in secureResponse() should mean 500
---
 java/org/apache/catalina/authenticator/AuthenticatorBase.java | 8 ++++++--
 webapps/docs/changelog.xml                                    | 6 ++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/AuthenticatorBase.java 
b/java/org/apache/catalina/authenticator/AuthenticatorBase.java
index 67c8fa3c97..c676793107 100644
--- a/java/org/apache/catalina/authenticator/AuthenticatorBase.java
+++ b/java/org/apache/catalina/authenticator/AuthenticatorBase.java
@@ -784,21 +784,25 @@ public abstract class AuthenticatorBase extends ValveBase 
implements Authenticat
 
             boolean result = authenticateJaspic(request, response, 
jaspicRequestState, true);
 
-            secureResponseJaspic(request, response, jaspicRequestState);
+            // '&' is deliberate since short-cut is not appropriate here - 
secureResponseJaspic() always needs to run.
+            result = result & secureResponseJaspic(request, response, 
jaspicRequestState);
 
             return result;
         }
     }
 
 
-    private void secureResponseJaspic(Request request, Response response, 
JaspicRequestState state) {
+    private boolean secureResponseJaspic(Request request, Response response, 
JaspicRequestState state) throws IOException {
         try {
             state.serverAuthContext.secureResponse(state.messageInfo, null);
             request.setRequest((HttpServletRequest) 
state.messageInfo.getRequestMessage());
             response.setResponse((HttpServletResponse) 
state.messageInfo.getResponseMessage());
         } catch (AuthException e) {
             log.warn(sm.getString("authenticator.jaspicSecureResponseFail"), 
e);
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+            return false;
         }
+        return true;
     }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 31f9f318e3..399ca9f643 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -324,6 +324,12 @@
         Use RequestDispatcher target rather than source when looking up
         <code>security-role-ref</code>s for the current Servlet. (markt)
       </fix>
+      <fix>
+        As per the Jakarta Authentication specification, an
+        <code>AuthException</code> during
+        <code>serverAuthContext.secureResponse()</code> should result in an
+        internal server error (500) response. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to