source: src/main/java/mk/finki/ukim/mk/vehiclerent/config/SecurityConfig.java@ 3965aed

Last change on this file since 3965aed was 3965aed, checked in by lepaSi <86915414+lepaSi@…>, 9 months ago

Init

  • Property mode set to 100644
File size: 1.2 KB
Line 
1package mk.finki.ukim.mk.vehiclerent.config;
2
3import org.springframework.context.annotation.Configuration;
4import org.springframework.security.config.annotation.web.builders.HttpSecurity;
5import org.springframework.security.config.annotation.web.builders.WebSecurity;
6import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
7import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
8
9@Configuration
10@EnableWebSecurity
11public class SecurityConfig extends WebSecurityConfigurerAdapter {
12
13 @Override
14 protected void configure(HttpSecurity http) throws Exception {
15 http.authorizeRequests()
16 .antMatchers("/", "/register","/login","/vehicles").permitAll()
17 .antMatchers().hasRole("KLIENT")
18 .antMatchers().hasRole("VRABOTEN")
19 .anyRequest().authenticated()
20 .and()
21 .logout()
22 .logoutUrl("/logout")
23 .invalidateHttpSession(true)
24 .logoutSuccessUrl("/");
25
26 }
27
28 @Override
29 public void configure(WebSecurity web) throws Exception {
30 web.ignoring().antMatchers("/webjars/**");
31 }
32}
Note: See TracBrowser for help on using the repository browser.