Skip to content

Commit

Permalink
Move configureCsrf into method that can also be invoked later for lat…
Browse files Browse the repository at this point in the history
…e filterChain registration additions. Also ignore situations where FilterChainProxy exists in classpath, but is not being used.
  • Loading branch information
codeconsole committed Nov 22, 2024
1 parent ee0ab1c commit 869a371
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import grails.gsp.TagLib
import groovy.transform.CompileStatic
import groovy.util.logging.Commons
import org.grails.plugins.web.GrailsTagDateHelper
import org.springframework.beans.BeansException

import java.text.DateFormat
import java.text.DateFormatSymbols
Expand Down Expand Up @@ -76,6 +77,10 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar
if (applicationContext.containsBean('mvcConversionService')) {
conversionService = applicationContext.getBean('mvcConversionService', ConversionService)
}
configureCsrf()
}

void configureCsrf() {
try {
var filterChainProxy = applicationContext.getBean(
Class.forName("org.springframework.security.web.FilterChainProxy"))
Expand All @@ -85,7 +90,7 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar
springSecurityCsrfTokenClass =
Class.forName("org.springframework.security.web.csrf.CsrfToken")
}
} catch (ClassNotFoundException ignore) {}
} catch (ClassNotFoundException | BeansException ignore) {}
}

/**
Expand Down

0 comments on commit 869a371

Please sign in to comment.