How to get past the Authentication Required Spring-boot Security

前端 未结 5 1151
无人共我
无人共我 2021-02-12 17:18

I have put in the password which is \"root\" and it keeps popping back up. How can I suppress this or get rid of it. I am using spring boot and spring security.

5条回答
  •  春和景丽
    2021-02-12 18:12

    When Spring Security is in the classpath, Spring Boot by default secures all your pages with Basic authentication. That's why you are being asked for userid and password.

    You will need to configure the security. To do so, commonly people would extend a WebSecurityConfigurerAdapter, like this:

    @Configuration
    public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http
                .authorizeRequests()
                    .antMatchers("/", "/home").permitAll()
                    .anyRequest().authenticated()
                    .and()
                ...
    

    Refer this Spring Security guide for more details.

提交回复
热议问题