source: sources/app/src/main/java/parkup/configs/webConfigs/WebSecurityConfig.java@ 9ff45d6

Last change on this file since 9ff45d6 was 9ff45d6, checked in by andrejTavchioski <andrej.tavchioski@…>, 3 years ago

Fixed some functionalities related to parkingSessions and parkingZones

  • Property mode set to 100644
File size: 2.7 KB
Line 
1package parkup.configs.webConfigs;
2
3import org.springframework.context.annotation.Bean;
4import org.springframework.context.annotation.Configuration;
5import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
6import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
7import org.springframework.security.config.annotation.web.builders.HttpSecurity;
8import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
9import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
10import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
11import parkup.services.RegistriranParkiracService;
12import parkup.services.VrabotenService;
13
14@EnableWebSecurity
15@Configuration
16public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
17 private final VrabotenService vrabotenService;
18 private final BCryptPasswordEncoder bCryptPasswordEncoder;
19 private final RegistriranParkiracService registriranParkiracService;
20
21 public WebSecurityConfig(VrabotenService vrabotenService, BCryptPasswordEncoder bCryptPasswordEncoder, RegistriranParkiracService registriranParkiracService) {
22 this.vrabotenService = vrabotenService;
23 this.bCryptPasswordEncoder = bCryptPasswordEncoder;
24 this.registriranParkiracService = registriranParkiracService;
25 }
26
27 @Override
28 protected void configure(HttpSecurity http) throws Exception {
29 http
30 .csrf().disable()
31 .authorizeRequests()
32 .antMatchers("/registriranParkirac/registration/**")
33 .permitAll()
34 .anyRequest()
35 .authenticated().and().formLogin();//ruta na viktor
36 }
37
38 @Override
39 protected void configure(AuthenticationManagerBuilder auth) throws Exception {
40 auth.authenticationProvider(daoAuthenticationProviderW());
41 auth.authenticationProvider(daoAuthenticationProviderRP());
42 }
43
44 @Bean
45 public DaoAuthenticationProvider daoAuthenticationProviderW() {
46 DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
47 provider.setPasswordEncoder(bCryptPasswordEncoder);
48 provider.setUserDetailsService(vrabotenService);
49 return provider;
50 }
51
52 @Bean
53 public DaoAuthenticationProvider daoAuthenticationProviderRP(){
54 DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
55 provider.setPasswordEncoder(bCryptPasswordEncoder);
56 provider.setUserDetailsService(registriranParkiracService);
57 return provider;
58 }
59
60 }
Note: See TracBrowser for help on using the repository browser.