addFilterAt

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

Adds the Filter at 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 {
addFilterAt<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 addFilterAt(filter: Filter, atFilter: Class<out Filter>)

Deprecated

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

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

Example:

@Configuration
@EnableWebSecurity
class SecurityConfig {

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

Parameters

filter

the Filter to register

atFilter

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