Skip to content

Commit

Permalink
Set filterChain position to match default position used by Spring Sec…
Browse files Browse the repository at this point in the history
…urity. Fixes #1033
  • Loading branch information
codeconsole committed Oct 31, 2024
1 parent 5b20efd commit c7e7725
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import grails.plugins.Plugin
import grails.util.Metadata
import groovy.util.logging.Slf4j
import org.grails.web.mime.HttpServletResponseExtension
import org.springframework.boot.autoconfigure.security.SecurityProperties
import org.springframework.boot.web.servlet.FilterRegistrationBean
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean
import org.springframework.cache.jcache.JCacheCacheManager
Expand Down Expand Up @@ -221,17 +222,7 @@ class SpringSecurityCoreGrailsPlugin extends Plugin {
filter = ref('springSecurityFilterChain')
urlPatterns = ['/*']
dispatcherTypes = EnumSet.of(DispatcherType.ERROR, DispatcherType.REQUEST)

// The filter chain has to be after grailsWebRequestFilter, but its order changed
// in 3.1 (from Ordered.HIGHEST_PRECEDENCE + 30 (-2147483618) to
// FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER + 30 (30))
String grailsVersion = Metadata.current.getGrailsVersion()
if (grailsVersion.startsWith('3.0')) {
order = Ordered.HIGHEST_PRECEDENCE + 100
}
else {
order = 100 // FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER + 100
}
order = SecurityProperties.DEFAULT_FILTER_ORDER
}

if (conf.useHttpSessionEventPublisher) {
Expand Down

0 comments on commit c7e7725

Please sign in to comment.