Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable spring-security login screen?

I'm using spring-boot-starter-security dependency, to make use of several classes that come with spring-security. But as I want to integrate it in an existing vaadin application, I only want to make use of the classes, and not of the default login/auth screen of spring.

How can I disable this screen?

I cannot make any configurations by extending WebSecurityConfigurerAdapter as my main entry class already extends SpringBootServletInitializer. Also, vaadin applications basically run on the same URL path all the time and use internal navigation.

@EnableAutoConfiguration
public class MyApp extends SpringBootServletInitializer { 

        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(MyApp.class);
        }

        public static void main(String[] args) {
            SpringApplication.run(MyApp.class, args);
        }
}

So, what could I do to disable the login screen, but though make use of spring security features?

like image 471
membersound Avatar asked May 13 '14 16:05

membersound


People also ask

How do I disable security in Spring Security?

enabled=false and management. security. enabled=false should be set to disable the security.

How do I disable spring boot security configuration?

In Spring Boot 2, if we want our own security configuration, we can simply add a custom WebSecurityConfigurerAdapter. This will disable the default auto-configuration and enable our custom security configuration.

How do I disable Defaultsecurityfilterchain?

In application. properties , set security. ignored=none .


4 Answers

you can use java based configuration like this :

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity security) throws Exception
    {
     security.httpBasic().disable();
    }
}

and restart your application if it's refresh automatically.

like image 129
noobdev Avatar answered Oct 22 '22 11:10

noobdev


The default security in Spring Boot is Basic. You could disable it by setting security.basic.enabled=false. More about this here and here.

like image 39
Andrei Stefan Avatar answered Oct 22 '22 09:10

Andrei Stefan


Disable the default spring security by excluding it from the autoconfiguration. Add SecurityAutoConfiguration.class to the exclude property of the @SpringBootApplication annotation on your main class. Like follows:

@SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
public class MyApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}
like image 11
Michiel Haisma Avatar answered Oct 22 '22 11:10

Michiel Haisma


There seems to be a simpler solution.

Simply put this annotationabove your main class or the same place as your SpingBootApplication annotation

@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class})

like image 7
Fangming Avatar answered Oct 22 '22 10:10

Fangming