source: sources/app/src/main/java/parkup/configs/WebSecurityConfig.java@ f6bc52d

Last change on this file since f6bc52d was f6bc52d, checked in by DavidTrajkovski <davidtrajkovski11@…>, 3 years ago

fixed delete methods

  • Property mode set to 100644
File size: 2.8 KB
Line 
1package parkup.configs;
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("/vraboten/registration/**")
33 .permitAll()
34 .antMatchers("/registriranParkirac/registration/**")
35 .permitAll()
36 .anyRequest()
37 .authenticated().and().formLogin();
38 }
39
40 @Override
41 protected void configure(AuthenticationManagerBuilder auth) throws Exception {
42 auth.authenticationProvider(daoAuthenticationProviderW());
43 auth.authenticationProvider(daoAuthenticationProviderRP());
44 }
45
46 @Bean
47 public DaoAuthenticationProvider daoAuthenticationProviderW() {
48 DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
49 provider.setPasswordEncoder(bCryptPasswordEncoder);
50 provider.setUserDetailsService(vrabotenService);
51 return provider;
52 }
53
54 @Bean
55 public DaoAuthenticationProvider daoAuthenticationProviderRP(){
56 DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
57 provider.setPasswordEncoder(bCryptPasswordEncoder);
58 provider.setUserDetailsService(registriranParkiracService);
59 return provider;
60 }
61
62 }
Note: See TracBrowser for help on using the repository browser.