addFilterAfter

inline fun <T : Filter> addFilterAfter(filter: Filter)

Adds the Filter after the location of the specified Filter class. Variant that is leveraging Kotlin reified type parameters.

Example:

@Configuration
@EnableWebSecurity
class SecurityConfig {

@Bean
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
http {
addFilterAfter<UsernamePasswordAuthenticationFilter>(CustomFilter())
}
return http.build()
}
}

Parameters

filter

the Filter to register

Type Parameters

T

the location of another Filter that is already registered (i.e. known) with Spring Security.


fun addFilterAfter(filter: Filter, afterFilter: Class<out Filter>)

Deprecated

Use 'addFilterAfter<T>(filter)' instead.

Adds the Filter after the location of the specified Filter class.

Example:

@Configuration
@EnableWebSecurity
class SecurityConfig {

@Bean
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
http {
addFilterAfter(CustomFilter(), UsernamePasswordAuthenticationFilter::class.java)
}
return http.build()
}
}

Parameters

filter

the Filter to register

afterFilter

the location of another Filter that is already registered (i.e. known) with Spring Security.