I have this filter :
@Override
protected void configure(HttpSecurity http) throws Exception {
http.requestMatchers(new RequestHeaderRequestMatcher("Caller", "Rem"));
// add here a seconde filter condition for basic Auth
}
Just After header filter, I want to make another filter in same configuration with the identifiers inMemory below:
@Autowired
public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.passwordEncoder(NoOpPasswordEncoder.getInstance())
.withUser("myAccount").password("MyPassword").roles("USER");
}
Thanks in adance.
http.httpBasic().and()
.authorizeRequests()
.requestMatchers(new AndRequestMatcher(new RequestHeaderRequestMatcher("Caller", "Rem"), new AntPathRequestMatcher("/hello/one")))
.hasRole("USER")
.and()
.authorizeRequests().anyRequest().authenticated()
.anyRequest().denyAll();
Replace "/hello/one" with "/**" in your scenario.
Explanation:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.