2015-11-11 77 views
2

我有multipart web項目。 Web Admin部分包括:春季啓動:禁用安全自動配置

compile('org.springframework.boot:spring-boot-starter-web') 
compile("org.springframework.boot:spring-boot-starter-thymeleaf") 
compile("org.springframework.boot:spring-boot-starter-jetty") 
compile("org.springframework.boot:spring-boot-starter-actuator") 

主要項目生成文件包含:

compile group: 'org.springframework', name: "spring-webmvc", version: springVersion 
compile(group: 'org.springframework.security', name: "spring-security-web", version: springSecurityVersion) { exclude(module: 'spring-jdbc') } 

春天啓動的應用程序文件:

@SpringBootApplication(exclude = {SecurityAutoConfiguration.class}) 
public class WebAdminApplication { 

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

但是,當我在做的http請求我的管理部分我m獲取用戶和密碼在我的AuthenticationProvider

auth.getPrincipal() -> user 
auth.getCredentials() -> caeebd3a-307b-4edf-8f2f-833fad9ebc00 

如何禁用自動安全功能?

+0

你想徹底禁用什麼?如果您不包含spring-security作爲依賴項,則spring-boot不會爲您自動配置它。如果你想要一個不同的配置,你需要自己配置它。 –

+0

我想禁用完全創建的默認用戶/密碼 – Lugaru

回答

2

如果你看看spring boot's spring.factories(在寫作的時候發佈1.3.5),你可以看到安全有4個自動配置類:

org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration,\ 
org.springframework.boot.autoconfigure.security.SecurityFilterAutoConfiguration,\ 
org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration,\ 
org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration,\ 

你可能想也禁用SecurityFilterAutoConfiguration(或它們的全部4 )