Line | |
---|
1 | package mk.finki.ukim.mk.vehiclerent.config;
|
---|
2 |
|
---|
3 | import org.springframework.context.annotation.Configuration;
|
---|
4 | import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
---|
5 | import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
---|
6 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
---|
7 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
---|
8 |
|
---|
9 | @Configuration
|
---|
10 | @EnableWebSecurity
|
---|
11 | public 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.