From 4d08e007be81acc215b4b880aeff76b42215cbe7 Mon Sep 17 00:00:00 2001 From: Lee junbeom Date: Sat, 29 Jun 2024 00:05:04 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=84=ED=9A=8C=EC=9B=90=20=EC=A0=84?= =?UTF-8?q?=EC=9A=A9=20api=EB=93=A4=EC=9D=80=20Spring=20security=EC=97=90?= =?UTF-8?q?=20=ED=8F=AC=ED=95=A8=20=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/flower/repository/FlowerRepository.java | 3 ++- .../domain/inputMessage/controller/api/ModelApi.java | 7 ------- .../fiurinee/global/security/config/SecurityConfig.java | 2 ++ .../fiurinee/global/security/filter/JwtVerifyFilter.java | 5 ++++- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/example/fiurinee/domain/flower/repository/FlowerRepository.java b/src/main/java/com/example/fiurinee/domain/flower/repository/FlowerRepository.java index c1c0210..4a071de 100644 --- a/src/main/java/com/example/fiurinee/domain/flower/repository/FlowerRepository.java +++ b/src/main/java/com/example/fiurinee/domain/flower/repository/FlowerRepository.java @@ -3,6 +3,7 @@ import com.example.fiurinee.domain.flower.entity.Flower; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -12,7 +13,7 @@ public interface FlowerRepository extends JpaRepository { @Query("SELECT f FROM Flower f WHERE f.period BETWEEN :startPeriod AND :endPeriod") - List findByPeriodMonth(Long startPeriod, Long endPeriod); + List findByPeriodMonth(@Param("startPeriod") Long startPeriod, @Param("endPeriod") Long endPeriod); Optional findByNameAndFlowerLanguage(String name,String flowerLanguage); } diff --git a/src/main/java/com/example/fiurinee/domain/inputMessage/controller/api/ModelApi.java b/src/main/java/com/example/fiurinee/domain/inputMessage/controller/api/ModelApi.java index 7f9a7e7..90c3c91 100644 --- a/src/main/java/com/example/fiurinee/domain/inputMessage/controller/api/ModelApi.java +++ b/src/main/java/com/example/fiurinee/domain/inputMessage/controller/api/ModelApi.java @@ -43,14 +43,7 @@ public ResponseEntity> inputMent(@Parameter(description = description = "비회원의 멘트 입력", security = @SecurityRequirement(name = "bearerAuth") ) - @Parameter( - in = ParameterIn.HEADER, - name = "Authorization", required = true, - schema = @Schema(type = "string"), - description = "Bearer [Access 토큰]" - ) @ApiResponse(responseCode = "200", description = "꽃 추천 성공") - @ApiResponse(responseCode = "401", description = "인증 실패") @PostMapping("/ment") public ResponseEntity> inputMentNotMember(@Parameter(description = "입력한 멘트") @RequestBody String ment); diff --git a/src/main/java/com/example/fiurinee/global/security/config/SecurityConfig.java b/src/main/java/com/example/fiurinee/global/security/config/SecurityConfig.java index 70c4371..9431234 100644 --- a/src/main/java/com/example/fiurinee/global/security/config/SecurityConfig.java +++ b/src/main/java/com/example/fiurinee/global/security/config/SecurityConfig.java @@ -70,6 +70,8 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti authorizationManagerRequestMatcherRegistry .requestMatchers("/oauth2/login", "/login/oauth2/code/**", "/oauth2/authorization/**","/login/oauth2/code/google","/member/*/refresh","/model/test", "/swagger-ui/index.html", "/swagger-ui/**", "/v3/api-docs/**","/swagger-resources/**", "/v3/api-docs").permitAll() + //비회원 전용 api + .requestMatchers("/main/today","/main/season","model/ment").permitAll() .anyRequest().authenticated()); http.addFilterBefore(jwtVerifyFilter(), UsernamePasswordAuthenticationFilter.class); diff --git a/src/main/java/com/example/fiurinee/global/security/filter/JwtVerifyFilter.java b/src/main/java/com/example/fiurinee/global/security/filter/JwtVerifyFilter.java index 517734d..cc8f5a2 100644 --- a/src/main/java/com/example/fiurinee/global/security/filter/JwtVerifyFilter.java +++ b/src/main/java/com/example/fiurinee/global/security/filter/JwtVerifyFilter.java @@ -26,7 +26,10 @@ public class JwtVerifyFilter extends OncePerRequestFilter { // 소셜 로그인 관련 URI 추가 private static final String[] whitelist = {"/signUp", "/login", "/refresh", "/", "/index.html", "/oauth2/login", "/login/oauth2/code/*", "/oauth2/authorization/kakao","/member/*/refresh","/model/test", - "/swagger-ui/index.html", "/swagger-ui/**", "/v3/api-docs/**", "/swagger-resources/**", "/v3/api-docs"}; + //Swagger + "/swagger-ui/index.html", "/swagger-ui/**", "/v3/api-docs/**", "/swagger-resources/**", "/v3/api-docs", + //비회원 전용 api + "/main/today","/main/season","model/ment"}; private final RedisUtil redisUtil;