- Timestamp:
- 11/11/21 11:55:43 (3 years ago)
- Branches:
- master
- Children:
- 2ace8f0
- Parents:
- 3a58bd6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/app/src/main/java/parkup/configs/WebSecurityConfig.java
r3a58bd6 r97fbc67 9 9 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 10 10 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 11 import parkup.services.AdministratorService; 11 import parkup.services.RegistriranParkiracService; 12 import parkup.services.VrabotenService; 12 13 14 @EnableWebSecurity 13 15 @Configuration 14 @EnableWebSecurity15 16 public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 17 private final VrabotenService vrabotenService; 18 private final BCryptPasswordEncoder bCryptPasswordEncoder; 19 private final RegistriranParkiracService registriranParkiracService; 16 20 17 private final AdministratorService administratorService; 18 private final BCryptPasswordEncoder bCryptPasswordEncoder; 21 public WebSecurityConfig(VrabotenService vrabotenService, BCryptPasswordEncoder bCryptPasswordEncoder, RegistriranParkiracService registriranParkiracService) { 22 this.vrabotenService = vrabotenService; 23 this.bCryptPasswordEncoder = bCryptPasswordEncoder; 24 this.registriranParkiracService = registriranParkiracService; 25 } 19 26 20 public WebSecurityConfig(AdministratorService administratorService, BCryptPasswordEncoder bCryptPasswordEncoder) { 21 this.bCryptPasswordEncoder = bCryptPasswordEncoder; 22 this.administratorService = administratorService; 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 23 62 } 24 25 @Override26 protected void configure(HttpSecurity http) throws Exception {27 http28 .csrf().disable()29 .authorizeRequests()30 .antMatchers("/administrator/registration/**")31 .permitAll()32 .anyRequest()33 .authenticated().and()34 .formLogin();35 }36 37 @Override38 protected void configure(AuthenticationManagerBuilder auth) throws Exception {39 auth.authenticationProvider(daoAuthenticationProvider());40 }41 42 @Bean43 public DaoAuthenticationProvider daoAuthenticationProvider(){44 DaoAuthenticationProvider provider = new DaoAuthenticationProvider();45 provider.setPasswordEncoder(bCryptPasswordEncoder);46 provider.setUserDetailsService(administratorService);47 return provider;48 }49 }
Note:
See TracChangeset
for help on using the changeset viewer.