From 09598445731c9766d9c983c108c91e0a1ac1be82 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Tue, 8 Oct 2024 23:57:14 -0700 Subject: [PATCH] Move sitemesh registration location --- .../springsecurity/SpringSecurityCoreGrailsPlugin.groovy | 6 ------ .../plugin/springsecurity/SpringSecurityUtils.groovy | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityCoreGrailsPlugin.groovy b/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityCoreGrailsPlugin.groovy index 5c52ade2..fe669878 100644 --- a/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityCoreGrailsPlugin.groovy +++ b/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityCoreGrailsPlugin.groovy @@ -670,12 +670,6 @@ to default to 'Annotation'; setting value to 'Annotation' } log.trace 'Using SecurityContextHolder strategy {}', SCH.strategyName - // 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 - if (applicationContext.getBean('sitemesh3Secured')) { - SpringSecurityUtils.clientRegisterFilter('sitemesh3Secured', SecurityFilterPosition.FORM_CONTENT_FILTER.previous()) - } - // build filters here to give dependent plugins a chance to register some SortedMap filterNames = ReflectionUtils.findFilterChainNames(conf) def securityFilterChains = applicationContext.securityFilterChains diff --git a/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityUtils.groovy b/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityUtils.groovy index 03f0110d..a54a1c7c 100644 --- a/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityUtils.groovy +++ b/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityUtils.groovy @@ -782,6 +782,13 @@ final class SpringSecurityUtils { 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.FORM_CONTENT_FILTER.previous().order] = sitemesh3Filter.filter + } log.trace 'Ordered filters: {}', SpringSecurityUtils.configuredOrderedFilters if (chainMap) {