1 Reply Latest reply on Mar 5, 2016 7:53 AM by cgum

    What's the best way to add a custom Filter to the various pluginXXX filter chains in Jive 8?


      Jive provides three plugin-extendable filter chain definitions in spring-securityContext.xml.  They are called pluginPreFilerChain, pluginPostSessionContextFilterChain, and pluginPostFilterChain.



      You can add your filters to a particular filter chain, depending on where in the main Request processing workflow you need your Filter to jump in.



      In Jive 7, I would use com.jivesoftware.jiveauth.util.FilterChainModifier which I found in this maven dependency:


      This dependency has not been updated for Jive 8, and there are some differences in the version of Spring used by Jive 8, so I took the FilterChainModifier and FilterChainUtils classes from that library and updated them to work with the new version of Spring.  I had no problems with this approach - I could have different plugins load their own custom filters into the different filter chains and they would work fine and peacefully coexist.  Once I deployed to our Jive-hosted v8 staging environment, however, I noticed that none of the Filters that I had added to the pluginPostSessionContextFilterChain were being executed.


      I believe this problem is being caused by Jive's hosting plugin


      It looks like they ran into the exact same issue as I did when upgrading to v8, but used a different solution to add their own custom filter to the pluginPostSessionContextFilterChain.  It may have worked, but I think it's preventing my plugins from being able to use the pluginPostSessionContextFilterChain.


      This is how Jive did it in v7 (essentially same as me) and v8 (new way?) in their hosting plugin (source provided by Jive)


      My question is, in Jive 8, how *SHOULD* I be merging filters into the various filter chains so that there are no conflicts with other plugins? 

        • Re: What's the best way to add a custom Filter to the various pluginXXX filter chains in Jive 8?



          I created two test plugins that essentially do the same thing - add a test filter to each of the three filter chains that log which filter chain they are in when you load up the /welcome page.  Using the same method as the v8 hosting plugin, I was able to see logging statements from both plugins in all three filter chains.


          For example:

          Make sure you don't leave out the "pattern" attribute on the <security:filter-chain> element or you will get an error that will most likely prevent your instance from starting up.


          I won't mark this a the "Correct" answer myself, but hopefully someone from Jive can verify.