[ 
https://issues.apache.org/jira/browse/FEDIZ-243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17031910#comment-17031910
 ] 

Arnaud MERGEY commented on FEDIZ-243:
-------------------------------------

A possible fix could be to update

*org.apache.cxf.fediz.tomcat8.handler.TomcatSigninHandler.createPrincipal(HttpServletRequest,
 HttpServletResponse, FedizResponse)*

And replace 

 
{code:java}
// Save the authenticated Principal in our session
session.setNote(Constants.FORM_PRINCIPAL_NOTE, principal);
{code}
with

 

 
{code:java}
register((Request) request, response, principal, 
FederationConstants.WSFED_METHOD, null, null);
{code}
And in

 

*org.apache.cxf.fediz.tomcat8.FederationAuthenticator.restoreRequest(Request, 
HttpServletResponse)*

*r*eplace

 
{code:java}
protected boolean restoreRequest(Request request, HttpServletResponse response) 
throws IOException {        
        Session session = request.getSessionInternal();
        LOG.debug("Restore request from session '{}'", 
session.getIdInternal());        // Get principal from session, register, and 
then remove it
        Principal principal = 
(Principal)session.getNote(Constants.FORM_PRINCIPAL_NOTE);
        register(request, response, principal, 
FederationConstants.WSFED_METHOD, null, null);
        request.removeNote(Constants.FORM_PRINCIPAL_NOTE);        if 
(restoreRequest(request)) {
            LOG.debug("Proceed to restored request");
            return true;
        } else {
            LOG.warn("Restore of original request failed");
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
            return false;
        }
    }
{code}
with

 
{code:java}
protected boolean restoreRequest(Request request, HttpServletResponse response) 
throws IOException {
 Session session = request.getSessionInternal();
 LOG.debug("Restore request from session '{}'", session.getIdInternal());
 if (restoreRequest(request)) {
  LOG.debug("Proceed to restored request");
  return true;
 } else {
  LOG.warn("Restore of original request failed");
  response.sendError(HttpServletResponse.SC_BAD_REQUEST);
  return false;
 }
 }
{code}
 

 

> Fediz tomcat valve is broken with recent tomcat version
> -------------------------------------------------------
>
>                 Key: FEDIZ-243
>                 URL: https://issues.apache.org/jira/browse/FEDIZ-243
>             Project: CXF-Fediz
>          Issue Type: Bug
>          Components: Plugin
>    Affects Versions: 1.4.6
>            Reporter: Arnaud MERGEY
>            Priority: Critical
>
> Since 8.5.50 and 9.0.30, the fediz tomcat valve stop working because of a 
> security fix done in FormAuthenticator 
> _Refactor FORM authentication to reduce duplicate code and to ensure that the 
> authenticated Principal is not cached in the session when caching is 
> disabled. (markt)_
> Which has been done with this commit 
> [https://github.com/apache/tomcat/commit/1ecba14e690cf5f3f143eef6ae7037a6d3c16652#diff-d3a23672da52a023e04cefd774dbe896]
> I need to investigate more, but I think the main issue is
> {code:java}
> in 
> org.apache.cxf.fediz.tomcat8.FederationAuthenticator.restoreRequest(Request, 
> HttpServletResponse) 
> Principal principal = 
> (Principal)session.getNote(Constants.FORM_PRINCIPAL_NOTE);
> {code}
>  
> is not working anymore as Constants.FORM_PRINCIPAL_NOTE is not used anymore



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to