|
|
|
@ -21,13 +21,13 @@ import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import javax.sql.DataSource; |
|
|
|
import javax.sql.DataSource; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|
|
|
import org.springframework.boot.builder.SpringApplicationBuilder; |
|
|
|
import org.springframework.boot.builder.SpringApplicationBuilder; |
|
|
|
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
|
|
|
|
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
|
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
|
|
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
|
|
|
|
|
|
|
import org.springframework.security.provisioning.JdbcUserDetailsManager; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
@ -63,9 +63,6 @@ public class SampleWebSecureJdbcApplication implements WebMvcConfigurer { |
|
|
|
@Configuration |
|
|
|
@Configuration |
|
|
|
protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter { |
|
|
|
protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private DataSource dataSource; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
http.authorizeRequests().antMatchers("/css/**").permitAll().anyRequest() |
|
|
|
http.authorizeRequests().antMatchers("/css/**").permitAll().anyRequest() |
|
|
|
@ -73,9 +70,11 @@ public class SampleWebSecureJdbcApplication implements WebMvcConfigurer { |
|
|
|
.failureUrl("/login?error").permitAll().and().logout().permitAll(); |
|
|
|
.failureUrl("/login?error").permitAll().and().logout().permitAll(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Bean |
|
|
|
public void configure(AuthenticationManagerBuilder auth) throws Exception { |
|
|
|
public JdbcUserDetailsManager jdbcUserDetailsManager(DataSource dataSource) { |
|
|
|
auth.jdbcAuthentication().dataSource(this.dataSource); |
|
|
|
JdbcUserDetailsManager jdbcUserDetailsManager = new JdbcUserDetailsManager(); |
|
|
|
|
|
|
|
jdbcUserDetailsManager.setDataSource(dataSource); |
|
|
|
|
|
|
|
return jdbcUserDetailsManager; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|