简体   繁体   中英

How to disable Spring Security's login screen? [duplicate]

This question already has an answer here:

Spring Security causes / or any path to redirect to /login , and /login to generate and serve a login form. I tried many options like adding these lines to my properties file

security.ignored=/**
spring.security.enabled=false
management.security.enabled=false
security.basic.enabled=false 

Nothing worked.

在此处输入图片说明

This has been deprecated maybe.

Seems security.ignored=/** has been moved out from Spring Boot 2.x as if Spring Security is on the classpath , Spring Boot will add @EnableWebSecurity so adding entries to the application.properties ain't gonna work.

Here is how you can disable by configuring security config...

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .antMatchers("/**").permitAll();
    }
}

Security changes in Spring Boot 2.0 M4

Remove Spring Security from the classpath:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
</dependency>

This will remove a barrier that forces the user to sign in before seeing a page.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM