source: src/main/java/com/example/medweb/config/SecurityConfig.java@ 5e4f0d7

Last change on this file since 5e4f0d7 was e5fefbd, checked in by Anita Terziska <63020646+Nit4e@…>, 2 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1package com.example.medweb.config;
2
3
4import org.springframework.context.annotation.Configuration;
5import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
6import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
7import org.springframework.security.config.annotation.web.builders.HttpSecurity;
8import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
9import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
10import org.springframework.security.crypto.password.PasswordEncoder;
11
12@Configuration
13@EnableWebSecurity
14@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true)
15public 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.