Ignore:
Timestamp:
11/11/21 11:55:43 (3 years ago)
Author:
andrejTavchioski <andrej.tavchioski@…>
Branches:
master
Children:
2ace8f0
Parents:
3a58bd6
Message:

fixed deleteVraboten and deleteRegistriranParkirac

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/app/src/main/java/parkup/configs/WebSecurityConfig.java

    r3a58bd6 r97fbc67  
    99import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
    1010import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
    11 import parkup.services.AdministratorService;
     11import parkup.services.RegistriranParkiracService;
     12import parkup.services.VrabotenService;
    1213
     14@EnableWebSecurity
    1315@Configuration
    14 @EnableWebSecurity
    1516public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
     17        private final VrabotenService vrabotenService;
     18        private final BCryptPasswordEncoder bCryptPasswordEncoder;
     19        private final RegistriranParkiracService registriranParkiracService;
    1620
    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        }
    1926
    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
    2362    }
    24 
    25     @Override
    26     protected void configure(HttpSecurity http) throws Exception {
    27         http
    28                 .csrf().disable()
    29                 .authorizeRequests()
    30                     .antMatchers("/administrator/registration/**")
    31                     .permitAll()
    32                 .anyRequest()
    33                 .authenticated().and()
    34                 .formLogin();
    35     }
    36 
    37     @Override
    38     protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    39         auth.authenticationProvider(daoAuthenticationProvider());
    40     }
    41 
    42     @Bean
    43     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.