Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- @EnableWebSecurity
- @ComponentScan(basePackages = {"com.onlineshop"})
- public class SecurityConfig extends WebSecurityConfigurerAdapter {
- @Autowired
- private BCryptPasswordEncoder bCryptPasswordEncoder;
- @Autowired
- private DataSource dataSource;
- @Value("${spring.queries.users-query}")
- private String usersQuery;
- @Value("${spring.queries.roles-query}")
- private String rolesQuery;
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http
- .authorizeRequests()
- .antMatchers("/css/**").permitAll()
- .anyRequest().authenticated()
- .and()
- .formLogin().permitAll()
- .and()
- .logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).permitAll();
- //.loginPage("/login").failureUrl("/login-error"); **/
- }
- @Autowired
- public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
- auth.
- jdbcAuthentication()
- .usersByUsernameQuery(usersQuery)
- .authoritiesByUsernameQuery(rolesQuery)
- .dataSource(dataSource)
- .passwordEncoder(bCryptPasswordEncoder);
- }
- }
- spring.datasource.url=jdbc:mysql://localhost:3306/onlineshop
- spring.datasource.username=root
- spring.datasource.password=root
- spring.datasource.tomcat.max-wait=20000
- spring.datasource.tomcat.max-active=50
- spring.datasource.tomcat.max-idle=20
- spring.datasource.tomcat.min-idle=15
- spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
- spring.jpa.properties.hibernate.id.new_generator_mappings = false
- spring.jpa.properties.hibernate.format_sql = true
- spring.jpa.hibernate.ddl-auto = update
- logging.level.org.springframework.web=DEBUG
- logging.level.org.hibernate=ERROR
- logging.level.org.hibernate.SQL=DEBUG
- logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
- logging.level.org.hibernate.type.descriptor.sql=trace
- hibernate.show_sql=true
Add Comment
Please, Sign In to add comment