From 5423b4547094f298ca677af2c943a926a184b551 Mon Sep 17 00:00:00 2001 From: Daniil Makeev Date: Wed, 19 Feb 2025 12:59:54 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D1=82=D0=B0=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD=D0=B0=D0=B4=20basic=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B5=D0=B9.=20=D0=98=D0=B4=D0=B5=D0=BC=20=D0=BE=D0=B1=D0=B4?= =?UTF-8?q?=D0=B5=D0=B4=D0=B0=D1=82=D1=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EmployeeController.java | 1 + .../CustomAuthenticationProvider.java | 19 +++++++++++++++++++ .../security/SecurityConfig.java | 16 ++++++++++++++++ .../security/SwaggerConfig.java | 13 +++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 src/main/java/com/example/onomatopoeiaback/security/CustomAuthenticationProvider.java create mode 100644 src/main/java/com/example/onomatopoeiaback/security/SecurityConfig.java create mode 100644 src/main/java/com/example/onomatopoeiaback/security/SwaggerConfig.java diff --git a/src/main/java/com/example/onomatopoeiaback/controller/EmployeeController.java b/src/main/java/com/example/onomatopoeiaback/controller/EmployeeController.java index 12451fb..e3f23e7 100644 --- a/src/main/java/com/example/onomatopoeiaback/controller/EmployeeController.java +++ b/src/main/java/com/example/onomatopoeiaback/controller/EmployeeController.java @@ -9,6 +9,7 @@ import com.example.onomatopoeiaback.service.EmployeeService; import com.example.onomatopoeiaback.service.VisitService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.List; diff --git a/src/main/java/com/example/onomatopoeiaback/security/CustomAuthenticationProvider.java b/src/main/java/com/example/onomatopoeiaback/security/CustomAuthenticationProvider.java new file mode 100644 index 0000000..78044c5 --- /dev/null +++ b/src/main/java/com/example/onomatopoeiaback/security/CustomAuthenticationProvider.java @@ -0,0 +1,19 @@ +package com.example.onomatopoeiaback.security; + +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.stereotype.Component; + +@Component +public class CustomAuthenticationProvider implements AuthenticationProvider { + @Override + public Authentication authenticate(Authentication authentication) throws AuthenticationException { + return null; + } + + @Override + public boolean supports(Class authentication) { + return false; + } +} diff --git a/src/main/java/com/example/onomatopoeiaback/security/SecurityConfig.java b/src/main/java/com/example/onomatopoeiaback/security/SecurityConfig.java new file mode 100644 index 0000000..e7971f6 --- /dev/null +++ b/src/main/java/com/example/onomatopoeiaback/security/SecurityConfig.java @@ -0,0 +1,16 @@ +package com.example.onomatopoeiaback.security; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Configurable; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.core.userdetails.UserDetailsService; + +@Configurable +@EnableWebSecurity +public class SecurityConfig { + @Autowired + private UserDetailsService userDetailsService; + + +} diff --git a/src/main/java/com/example/onomatopoeiaback/security/SwaggerConfig.java b/src/main/java/com/example/onomatopoeiaback/security/SwaggerConfig.java new file mode 100644 index 0000000..a070c56 --- /dev/null +++ b/src/main/java/com/example/onomatopoeiaback/security/SwaggerConfig.java @@ -0,0 +1,13 @@ +package com.example.onomatopoeiaback.security; + +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import org.springframework.context.annotation.Configuration; + +@Configuration +@SecurityScheme( + type = SecuritySchemeType.HTTP, + name = "basicAuth", + scheme = "basic") +public class SwaggerConfig { +}