问题
I override configure(HttpSecurity http)
method in SampleSecurityConfig Class like this
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/delete/**").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.formLogin().and().httpBasic();
}
If i don't use httpBasic
method, it seems no problem occurred.
what does httpBasic
method exactly do?
回答1:
Calling this method on HttpSecurity
will enable Http Basic Authentication for your application with some "reasonable" defaults.
It will return a HttpBasicConfigurer for further customization.
You can test this by curl and passing a header like Authorization: Basic bzFbdGfmZrptWY30YQ==
but base64 encoding a valid username/password combination.
Documentation for httpBasic
来源:https://stackoverflow.com/questions/57574981/what-is-httpbasic-method-in-spring-security