From eeef96ffb69999b0f0b4cae28d56390f4df13e84 Mon Sep 17 00:00:00 2001 From: Marc Beyer Date: Mon, 10 Jan 2022 13:25:52 +0100 Subject: [PATCH] Fixed Spring security --- server/build.gradle | 4 +-- .../vpr/server/controller/UserController.java | 1 + .../server/security/WebSecurityConfig.java | 31 ------------------- 3 files changed, 3 insertions(+), 33 deletions(-) delete mode 100644 server/src/main/java/com/vpr/server/security/WebSecurityConfig.java diff --git a/server/build.gradle b/server/build.gradle index 30e4c3f..6bf44d8 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -19,8 +19,8 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' // Spring security - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.security:spring-security-test' + //implementation 'org.springframework.boot:spring-boot-starter-security' + //implementation 'org.springframework.security:spring-security-test' // JSON web token implementation 'io.jsonwebtoken:jjwt-api:0.11.2' diff --git a/server/src/main/java/com/vpr/server/controller/UserController.java b/server/src/main/java/com/vpr/server/controller/UserController.java index be61bdc..63d2961 100644 --- a/server/src/main/java/com/vpr/server/controller/UserController.java +++ b/server/src/main/java/com/vpr/server/controller/UserController.java @@ -63,6 +63,7 @@ public class UserController { @RequestParam String login, @RequestParam String password ) { + System.out.println("LOGIN"); User user = userRepository.findByLogin(login); if (user == null) { throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Falscher login"); diff --git a/server/src/main/java/com/vpr/server/security/WebSecurityConfig.java b/server/src/main/java/com/vpr/server/security/WebSecurityConfig.java deleted file mode 100644 index b40aa85..0000000 --- a/server/src/main/java/com/vpr/server/security/WebSecurityConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.vpr.server.security; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.provisioning.InMemoryUserDetailsManager; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - @Override - protected void configure(HttpSecurity http) throws Exception { - http - .authorizeRequests() - .antMatchers("/", "/home").permitAll() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .permitAll() - .and() - .logout() - .permitAll(); - } - -}