Guest User

Untitled

a guest
Nov 13th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. @Configuration
  2. @EnableWebSecurity
  3. @ComponentScan(basePackages = {"com.onlineshop"})
  4. public class SecurityConfig extends WebSecurityConfigurerAdapter {
  5.  
  6. @Autowired
  7. private BCryptPasswordEncoder bCryptPasswordEncoder;
  8.  
  9. @Autowired
  10. private DataSource dataSource;
  11.  
  12. @Value("${spring.queries.users-query}")
  13. private String usersQuery;
  14.  
  15. @Value("${spring.queries.roles-query}")
  16. private String rolesQuery;
  17.  
  18.  
  19. @Override
  20. protected void configure(HttpSecurity http) throws Exception {
  21. http
  22. .authorizeRequests()
  23. .antMatchers("/css/**").permitAll()
  24. .anyRequest().authenticated()
  25. .and()
  26. .formLogin().permitAll()
  27. .and()
  28. .logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).permitAll();
  29. //.loginPage("/login").failureUrl("/login-error"); **/
  30. }
  31.  
  32. @Autowired
  33. public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
  34. auth.
  35. jdbcAuthentication()
  36. .usersByUsernameQuery(usersQuery)
  37. .authoritiesByUsernameQuery(rolesQuery)
  38. .dataSource(dataSource)
  39. .passwordEncoder(bCryptPasswordEncoder);
  40. }
  41. }
  42.  
  43. spring.datasource.url=jdbc:mysql://localhost:3306/onlineshop
  44. spring.datasource.username=root
  45. spring.datasource.password=root
  46. spring.datasource.tomcat.max-wait=20000
  47. spring.datasource.tomcat.max-active=50
  48. spring.datasource.tomcat.max-idle=20
  49. spring.datasource.tomcat.min-idle=15
  50.  
  51. spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
  52. spring.jpa.properties.hibernate.id.new_generator_mappings = false
  53. spring.jpa.properties.hibernate.format_sql = true
  54. spring.jpa.hibernate.ddl-auto = update
  55.  
  56. logging.level.org.springframework.web=DEBUG
  57. logging.level.org.hibernate=ERROR
  58.  
  59. logging.level.org.hibernate.SQL=DEBUG
  60. logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
  61. logging.level.org.hibernate.type.descriptor.sql=trace
  62. hibernate.show_sql=true
Add Comment
Please, Sign In to add comment