Last change
on this file was e5fefbd, checked in by Anita Terziska <63020646+Nit4e@…>, 2 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[e5fefbd] | 1 | package com.example.medweb.config;
|
---|
| 2 |
|
---|
| 3 |
|
---|
| 4 | import org.springframework.context.annotation.Configuration;
|
---|
| 5 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
---|
| 6 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
---|
| 7 | import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
---|
| 8 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
---|
| 9 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
---|
| 10 | import org.springframework.security.crypto.password.PasswordEncoder;
|
---|
| 11 |
|
---|
| 12 | @Configuration
|
---|
| 13 | @EnableWebSecurity
|
---|
| 14 | @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true)
|
---|
| 15 | public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
---|
| 16 |
|
---|
| 17 | private final PasswordEncoder passwordEncoder;
|
---|
| 18 |
|
---|
| 19 | public SecurityConfig(PasswordEncoder passwordEncoder) {
|
---|
| 20 | this.passwordEncoder = passwordEncoder;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | @Override
|
---|
| 24 | protected void configure(HttpSecurity http) throws Exception {
|
---|
| 25 | http.csrf().disable()
|
---|
| 26 | .authorizeRequests()
|
---|
| 27 | .antMatchers("/**").permitAll()
|
---|
| 28 | .and()
|
---|
| 29 | .logout()
|
---|
| 30 | .logoutUrl("/logout")
|
---|
| 31 | .clearAuthentication(true)
|
---|
| 32 | .invalidateHttpSession(true)
|
---|
| 33 | .logoutSuccessUrl("/");
|
---|
| 34 |
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.