Skip to content

Commit

Permalink
[FIX] Cookie 사용 여부 변경에 따른 Reissue 로직 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
tidavid1 committed Feb 22, 2024
1 parent 94d3bbe commit 8c96723
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

import io.oeid.mogakgo.core.properties.swagger.error.SwaggerAuthErrorExamples;
import io.oeid.mogakgo.domain.auth.presentation.dto.req.AuthReissueRequest;
import io.oeid.mogakgo.domain.auth.presentation.dto.res.AuthAccessTokenResponse;
import io.oeid.mogakgo.exception.dto.ErrorResponse;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -32,5 +33,5 @@ public interface AuthSwagger {
})
ResponseEntity<AuthAccessTokenResponse> reissue(
@Parameter(in = ParameterIn.HEADER, hidden = true) String accessToken,
@Parameter(in = ParameterIn.COOKIE) String refreshToken);
AuthReissueRequest refreshToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import io.oeid.mogakgo.common.swagger.template.AuthSwagger;
import io.oeid.mogakgo.domain.auth.application.AuthService;
import io.oeid.mogakgo.domain.auth.presentation.dto.req.AuthReissueRequest;
import io.oeid.mogakgo.domain.auth.presentation.dto.res.AuthAccessTokenResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -20,9 +21,8 @@ public class AuthController implements AuthSwagger {

@PostMapping("/reissue")
public ResponseEntity<AuthAccessTokenResponse> reissue(
@RequestHeader("Authorization") String accessToken,
@CookieValue("refreshToken") String refreshToken) {
var accessTokenDto = authService.reissue(accessToken, refreshToken);
@RequestHeader("Authorization") String accessToken, @RequestBody AuthReissueRequest request) {
var accessTokenDto = authService.reissue(accessToken, request.getRefreshToken());
return ResponseEntity.ok(AuthAccessTokenResponse.of(accessTokenDto.getAccessToken(), null));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.oeid.mogakgo.domain.auth.presentation.dto.req;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
@Schema(description = "토큰 재발급 요청")
public class AuthReissueRequest {

@Schema(description = "Refresh Token")
private final String refreshToken;
}

0 comments on commit 8c96723

Please sign in to comment.