@@ -0,0 +1,2374 @@
+package bg.car_wash.configurations;%0A%0Aimport bg.car_wash.services.UserService;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;%0Aimport org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;%0Aimport org.springframework.security.config.annotation.web.builders.HttpSecurity;%0Aimport org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;%0Aimport org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;%0Aimport org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;%0A%0A@Configuration%0A@EnableWebSecurity%0A@EnableGlobalMethodSecurity(prePostEnabled = true)%0Apublic class SpringSecurityConfig extends WebSecurityConfigurerAdapter %7B%0A%0A%09@Autowired%0A%09private UserService userService;%0A%0A%09@Override%0A%09protected void configure(AuthenticationManagerBuilder auth) throws Exception %7B%0A%09%09auth.userDetailsService(this.userService).passwordEncoder(getBCryptPasswordEncoder());%0A%09%7D%0A%0A%09@Override%0A%09protected void configure(HttpSecurity http) throws Exception %7B%0A%09%09http%0A%09%09%09%09.authorizeRequests()%0A%09%09%09%09.antMatchers(%22/%22, %22/register%22, %22/bootstrap/**%22, %22/jquery/**%22).permitAll()%0A//                .antMatchers(%22/user/**%22).access(%22hasRole('ADMIN') OR hasRole('USER')%22)%0A//                .antMatchers(%22/admin/**%22).hasRole(%22ADMIN%22)%0A//                .anyRequest().authenticated()%0A//                .and()%0A//                .formLogin().loginPage(%22/login%22).permitAll()%0A//                .usernameParameter(%22username%22)%0A//                .passwordParameter(%22password%22)%0A//                .and()%0A//                .rememberMe()%0A//                .rememberMeCookieName(%22RememberMeFromLecture%22)%0A//                .rememberMeParameter(%22rememberMe%22)%0A//                .key(%22GolqmTaina%22)%0A//                .tokenValiditySeconds(1000)%0A//                .and()%0A//                .logout().logoutSuccessUrl(%22/login?logout%22).permitAll()%0A//                .and()%0A//                .exceptionHandling().accessDeniedPage(%22/unauthorized%22)%0A%09%09%09%09.and()%0A%09%09%09%09.csrf().disable();%0A%09%7D%0A%0A%09@Bean%0A%09public BCryptPasswordEncoder getBCryptPasswordEncoder() %7B%0A%09%09return new BCryptPasswordEncoder();%0A%09%7D%0A%7D%0A

add spring security configuration