Goal:#
I want to modify the request sent by the frontend in the filter, so I initially inherited a WebSecurityConfigurerAdapter and overrode the configure method to add a custom filter. However, I could never enter this custom filter.
Analysis:#
First, we configured a resource server
Secondly, we configured a WebSecurityConfigurerAdapter
After running the resource server, the following code segment will be entered
The value of configurers corresponds to
It can be seen that configurers will contain two values, which respectively call the configuration of the resource server and the custom WebSecurityConfigurerAdapter configuration. Then, both will enter the WebSecurityConfigurerAdapter class and execute the following code segment
It can be seen that a new HttpSecurity object is created here, and filters are added to the corresponding HttpSecurity object in the subsequent steps. From here, it can be known that the filters added by the two configurations do not affect each other.
Finally, two filterChains are generated, and only the first one is executed in the end (because both match anyRequest, so the first one is executed first?)