diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 608fbcc..4d6f6fe 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,15 +4,11 @@
-
+
-
+
-
-
-
-
-
+
@@ -22,8 +18,8 @@
@@ -187,7 +183,15 @@
1740045412863
-
+
+
+ 1740049179417
+
+
+
+ 1740049179417
+
+
@@ -202,7 +206,8 @@
-
+
+
diff --git a/pom.xml b/pom.xml
index 7059282..3693ac4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,6 +33,12 @@
org.postgresql
postgresql
+
+ junit
+ junit
+ 4.13.2
+ test
+
org.thymeleaf.extras
thymeleaf-extras-springsecurity6
diff --git a/src/main/java/com/example/nto/controller/AuthController.java b/src/main/java/com/example/nto/controller/AuthController.java
index 8a0861f..807c3cc 100644
--- a/src/main/java/com/example/nto/controller/AuthController.java
+++ b/src/main/java/com/example/nto/controller/AuthController.java
@@ -39,15 +39,6 @@ public class AuthController {
@AllArgsConstructor
private static class LoginBody {
private String login;
- private String password;
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
public String getLogin() {
return login;
@@ -67,17 +58,7 @@ public class AuthController {
*/
@PostMapping("/api/login/")
private RoleResponse login(HttpServletRequest request, @RequestBody LoginBody loginBody) { //, @RequestParam String login, @RequestParam String password) {
-
Employee employee = employeeRepository.getByLogin(loginBody.login).get();
- List authorities = new ArrayList<>();
- authorities.add(new SimpleGrantedAuthority(employee.getRole()));
- UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(
- loginBody.getLogin(), loginBody.getPassword(), authorities);
- Authentication authentication = authenticationManager.authenticate(authRequest);
- SecurityContext securityContext = SecurityContextHolder.getContext();
- securityContext.setAuthentication(authentication);
- HttpSession session = request.getSession(true);
- session.setAttribute("SPRING_SECURITY_CONTEXT", securityContext);
RoleResponse response = new RoleResponse();
response.setRole(employee.getRole());
return response;
diff --git a/src/main/java/com/example/nto/websecurity/WebSecurityConfig.java b/src/main/java/com/example/nto/websecurity/WebSecurityConfig.java
index 9baca6e..00dffa0 100644
--- a/src/main/java/com/example/nto/websecurity/WebSecurityConfig.java
+++ b/src/main/java/com/example/nto/websecurity/WebSecurityConfig.java
@@ -85,6 +85,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.and()
.formLogin().permitAll()
.and()
- .logout().permitAll();
+ .logout().permitAll()
+ .and().httpBasic();
}
}