-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Description
Describe the bug
When setting up HttpSecurity it is possible to end up with the wrong order for filters by calling addFilterBefore multiple times.
To Reproduce
Start standard spring boot app with a class SecurityConfiguration extends WebSecurityConfigurerAdapter, override protected void configure(HttpSecurity http) throws Exception.
Do the following:
http
... standard setup ...
.addFilterBefore( myFilter, SomeFilterAtPosition100 )
.addFilterBefore( myFilter, SomeFilterAtPosition500 )
...
Then observe the order the filters are called, myFilter should be called before SomeFilterAtPosition100 and SomeFilterAtPosition500, however you will find it is only before SomeFilterAtPosition500, and in fact it is at position 499.
You will find the same issue with addFilterAfter
Expected behavior
myFilter should be before both SomeFilterAtPosition100 and SomeFilterAtPosition500, most likely at position 99
To be clear, it should be before or after all filters as you specify in the HttpSecurity setup.
Pull request with code changes to fix this issue:
master...Psynbiotik:patch-1