saumya
saumya

Reputation: 23

Springboot with multiple filters

I am using spring boot and integrated Azure AD. For that, I have used AADAuthenticationFilter.

In my WebSecurityConfig which extends WebSecurityConfigurerAdapter I have written:

http.addFilterBefore(aadAuthFilter, UsernamePasswordAuthenticationFilter.class);

How to add one more filter before executing the above line, for doing some custom filtering?

Upvotes: 2

Views: 5289

Answers (1)

catch32
catch32

Reputation: 18582

You could use Order annotation.

The value Ordered.HIGHEST_PRECEDENCE can be used for overriding the highest priority among components.

@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class MyFilter implements Filter {

Or you could control order at a more controlled way, like for the first one:

@Order(1)

For second:

@Order(2)

Useful reference:

Upvotes: 1

Related Questions