Skip to content

Commit

Permalink
Ensure sitemesh 3 is in correct place in filter chain
Browse files Browse the repository at this point in the history
  • Loading branch information
codeconsole committed Oct 11, 2024
1 parent 5ae99b3 commit b0af376
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,14 @@ to default to 'Annotation'; setting value to 'Annotation'
// build filters here to give dependent plugins a chance to register some
SortedMap<Integer, String> filterNames = ReflectionUtils.findFilterChainNames(conf)
def securityFilterChains = applicationContext.securityFilterChains

// if sitemesh 3 is installed, an additional sitemesh 3 filter will need to be registered
// as part of the security filter chain so that pages are decorated using the security context
def sitemesh3Filter = applicationContext.getBean('sitemesh3Secured')
if (sitemesh3Filter) {
filterNames[SecurityFilterPosition.EXCEPTION_TRANSLATION_FILTER.order - 10] = 'sitemesh3Secured'
}

SpringSecurityUtils.buildFilterChains filterNames, conf.filterChain.chainMap ?: [], securityFilterChains, applicationContext
log.trace 'Filter chain: {}', securityFilterChains

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,16 +778,12 @@ final class SpringSecurityUtils {

def allConfiguredFilters = [:]
filterNames.each { Integer order, String name ->
Filter filter = applicationContext.getBean(name, Filter)
allConfiguredFilters[name] = filter
SpringSecurityUtils.configuredOrderedFilters[order] = filter
}
// if sitemesh 3 is installed, an additional sitemesh 3 filter will need to be registered
// as part of the security filter chain so that pages are decorated using the security context
FilterRegistrationBean sitemesh3Filter = (FilterRegistrationBean) applicationContext.getBean('sitemesh3Secured')
if (sitemesh3Filter) {
allConfiguredFilters['sitemesh3Secured'] = sitemesh3Filter.filter
SpringSecurityUtils.configuredOrderedFilters[SecurityFilterPosition.EXCEPTION_TRANSLATION_FILTER.order - 10] = sitemesh3Filter.filter
def filter = applicationContext.getBean(name)
if (filter instanceof FilterRegistrationBean) {
filter = ((FilterRegistrationBean) filter).filter
}
allConfiguredFilters[name] = (Filter) filter
SpringSecurityUtils.configuredOrderedFilters[order] = (Filter) filter
}
log.trace 'Ordered filters: {}', SpringSecurityUtils.configuredOrderedFilters

Expand Down

0 comments on commit b0af376

Please sign in to comment.