diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberApi.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberApi.java index 33fa2d7..8aa05ab 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberApi.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberApi.java @@ -45,6 +45,13 @@ public CommonResponse testGenerateToken() { @Operation(summary = "02-01 Member\uD83D\uDC64 소셜 로그인 V1", description = "구글, 애플 소셜로그인 API입니다.") @PostMapping("/members/auth/{socialType}") + @ApiResponses({ + @ApiResponse(responseCode = "1000", description = "OK, 성공"), + @ApiResponse( + responseCode = "COMMON001", + description = "request body에 담길 값이 이상함, result를 확인해주세요!", + content = @Content(schema = @Schema(implementation = CommonResponse.class))), + }) public CommonResponse login( @Parameter(description = "소셜로그인 종류", example = "google") @PathVariable final SocialType socialType, diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/redis/service/RedisServiceImpl.java b/Briefing-Api/src/main/java/com/example/briefingapi/redis/service/RedisServiceImpl.java index 29ef3ce..8d9ccce 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/redis/service/RedisServiceImpl.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/redis/service/RedisServiceImpl.java @@ -47,7 +47,7 @@ public RefreshToken generateRefreshToken(String socialId, SocialType socialType) LocalDateTime currentTime = LocalDateTime.now(); - LocalDateTime expireTime = currentTime.plus(1000, ChronoUnit.MINUTES); + LocalDateTime expireTime = currentTime.plus(90, ChronoUnit.SECONDS); return refreshTokenRepository.save( RefreshToken.builder() @@ -68,8 +68,6 @@ public RefreshToken reGenerateRefreshToken(MemberRequest.ReissueDTO request) { () -> new RefreshTokenException(ErrorCode.INVALID_REFRESH_TOKEN)); LocalDateTime expireTime = findRefreshToken.getExpireTime(); LocalDateTime current = LocalDateTime.now(); - // 테스트용, 실제로는 현재 시간 + accessToken 만료 시간 - LocalDateTime expireDeadLine = current.plusSeconds(20); Member member = memberRepository @@ -80,13 +78,8 @@ public RefreshToken reGenerateRefreshToken(MemberRequest.ReissueDTO request) { logger.error("이미 만료된 리프레시 토큰 발견"); throw new RefreshTokenException(ErrorCode.RELOGIN_EXCEPTION); } - - // 새로 발급할 accessToken보다 refreshToken이 먼저 만료 될 경우인가? - if (expireTime.isAfter(expireDeadLine)) { - logger.info("기존 리프레시 토큰 발급"); - return findRefreshToken; - } else { - logger.info("accessToken보다 먼저 만료될 예정인 리프레시 토큰 발견"); + else{ + logger.info("리프레시 토큰과 access 토큰 재발급"); deleteRefreshToken(request.getRefreshToken()); return generateRefreshToken(member.getSocialId(), member.getSocialType()); } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/security/config/SecurityConfig.java b/Briefing-Api/src/main/java/com/example/briefingapi/security/config/SecurityConfig.java index a474b9d..ad1f4d3 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/security/config/SecurityConfig.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/security/config/SecurityConfig.java @@ -82,7 +82,7 @@ public WebSecurityCustomizer webSecurityCustomizer() { "/schedule", "/v3/api-docs", "/v3/api-docs/**", - "/docs/**","/fcms/**", + "/docs/**","/fcms/**","/members/auth/**", "/briefings/temp"); } @@ -138,6 +138,7 @@ public SecurityFilterChain JwtFilterChain(HttpSecurity http) throws Exception { .authenticated(); authorize.requestMatchers("/v2/scraps/**").authenticated(); authorize.requestMatchers("/scraps/**").authenticated(); + authorize.requestMatchers("/members/auth/token").permitAll(); authorize.anyRequest().authenticated(); }) .exceptionHandling( diff --git a/Briefing-Api/src/main/resources/application.yml b/Briefing-Api/src/main/resources/application.yml index bb1eaee..5167afd 100644 --- a/Briefing-Api/src/main/resources/application.yml +++ b/Briefing-Api/src/main/resources/application.yml @@ -119,7 +119,7 @@ jwt: secret: ${JWT_SECRET} # secret : ${JWT_SECRET} authorities-key: authoritiesKey - access-token-validity-in-seconds: 1210000000 # 30 m + access-token-validity-in-seconds: 30 # 30 m refresh-token-validity-in-seconds: 1210000000 # 14 d openai: @@ -159,7 +159,7 @@ jwt: secret: ${JWT_SECRET} # secret : ${JWT_SECRET} authorities-key: authoritiesKey - access-token-validity-in-seconds: 1210000000 # 30 m + access-token-validity-in-seconds: 1800 # 30 m refresh-token-validity-in-seconds: 1210000000 # 14 d openai: