Spring Boot 2 security basic authentication

后端 未结 2 1946
一向
一向 2021-01-23 16:25

Why following basic security configurations do not apply inMemoryAuthentication() clause?

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extend         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-23 17:04

    Do not call super method from void configure(AuthenticationManagerBuilder auth). It sets disableLocalConfigureAuthenticationBldr flag to true that leads to your AuthenticationManagerBuilder being ignored. Finally your void configure(AuthenticationManagerBuilder auth) method should look like this:

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
                .withUser("username").password("password").roles("USER");
    }
    

提交回复
热议问题