Skip to content

Commit bf0c8fc

Browse files
author
Dave Syer
committed
Remove JDBC from secure-web sample
Fixes gh-1534
1 parent 9902f98 commit bf0c8fc

File tree

2 files changed

+6
-35
lines changed

2 files changed

+6
-35
lines changed

spring-boot-samples/spring-boot-sample-web-secure/pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,10 @@
2323
<groupId>org.springframework.boot</groupId>
2424
<artifactId>spring-boot-starter-security</artifactId>
2525
</dependency>
26-
<dependency>
27-
<groupId>org.springframework.boot</groupId>
28-
<artifactId>spring-boot-starter-jdbc</artifactId>
29-
</dependency>
3026
<dependency>
3127
<groupId>org.springframework.boot</groupId>
3228
<artifactId>spring-boot-starter-thymeleaf</artifactId>
3329
</dependency>
34-
<dependency>
35-
<groupId>com.h2database</groupId>
36-
<artifactId>h2</artifactId>
37-
</dependency>
3830
<dependency>
3931
<groupId>org.apache.httpcomponents</groupId>
4032
<artifactId>httpclient</artifactId>

spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/ui/secure/SampleWebSecureApplication.java

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,14 @@
1919
import java.util.Date;
2020
import java.util.Map;
2121

22-
import javax.sql.DataSource;
23-
2422
import org.springframework.beans.factory.annotation.Autowired;
2523
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2624
import org.springframework.boot.autoconfigure.security.SecurityProperties;
2725
import org.springframework.boot.builder.SpringApplicationBuilder;
28-
import org.springframework.context.annotation.Bean;
2926
import org.springframework.context.annotation.ComponentScan;
30-
import org.springframework.core.Ordered;
27+
import org.springframework.context.annotation.Configuration;
3128
import org.springframework.core.annotation.Order;
3229
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
33-
import org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter;
3430
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
3531
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
3632
import org.springframework.stereotype.Controller;
@@ -65,16 +61,7 @@ public void addViewControllers(ViewControllerRegistry registry) {
6561
registry.addViewController("/login").setViewName("login");
6662
}
6763

68-
@Bean
69-
public ApplicationSecurity applicationSecurity() {
70-
return new ApplicationSecurity();
71-
}
72-
73-
@Bean
74-
public AuthenticationSecurity authenticationSecurity() {
75-
return new AuthenticationSecurity();
76-
}
77-
64+
@Configuration
7865
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
7966
protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter {
8067

@@ -86,20 +73,12 @@ protected void configure(HttpSecurity http) throws Exception {
8673
http.authorizeRequests().anyRequest().fullyAuthenticated().and().formLogin()
8774
.loginPage("/login").failureUrl("/login?error").permitAll();
8875
}
89-
}
90-
91-
@Order(Ordered.HIGHEST_PRECEDENCE + 10)
92-
protected static class AuthenticationSecurity extends
93-
GlobalAuthenticationConfigurerAdapter {
94-
95-
@Autowired
96-
private DataSource dataSource;
9776

9877
@Override
99-
public void init(AuthenticationManagerBuilder auth) throws Exception {
100-
auth.jdbcAuthentication().dataSource(this.dataSource).withUser("admin")
101-
.password("admin").roles("ADMIN", "USER").and().withUser("user")
102-
.password("user").roles("USER");
78+
public void configure(AuthenticationManagerBuilder auth) throws Exception {
79+
auth.inMemoryAuthentication().withUser("admin").password("admin")
80+
.roles("ADMIN", "USER").and().withUser("user").password("user")
81+
.roles("USER");
10382
}
10483

10584
}

0 commit comments

Comments
 (0)