Skip to content

Commit

Permalink
[CHORE] Auth API implements 키워드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
unanchoi committed Mar 12, 2024
1 parent 565b614 commit 77a8d79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

import java.security.NoSuchAlgorithmException;
import java.security.Principal;
import java.security.spec.InvalidKeySpecException;

import static io.swagger.v3.oas.annotations.enums.ParameterIn.HEADER;

Expand All @@ -26,7 +28,7 @@ public interface AuthApi {
@ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"),
@ApiResponse(responseCode = "500", description = "서버 내부 오류")
})
ResponseEntity<BaseResponse<?>> signIn(@RequestHeader("Authorization") final String socialAccessToken, @RequestBody SignInRequest request);
ResponseEntity<BaseResponse<?>> signIn(@RequestHeader("Authorization") final String socialAccessToken, @RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException;

@Operation(summary = "토큰 재발급 API")
@Parameter(name = "Authorization", description = "Bearer ${Smeme Refresh Token}", in = HEADER, required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,34 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("api/v2/auth")
public class AuthController {
public class AuthController implements AuthApi {

private final AuthService authService;
private final TokenService tokenService;

@Override
@PostMapping
public ResponseEntity<BaseResponse<?>> signIn(@RequestHeader("Authorization") final String socialAccessToken,
@RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException {
val response = SignInResponse.from(authService.signIn(socialAccessToken, SignInServiceRequest.of(request)));
return ApiResponseUtil.success(SUCCESS_SIGNIN, response);
}

@Override
@PostMapping("/token")
public ResponseEntity<BaseResponse<?>> reissueToken(Principal principal) {
val response = TokenResponse.from(tokenService.issueToken(Util.getMemberId(principal)));
return ApiResponseUtil.success(SUCCESS_ISSUE_TOKEN, response);
}

@Override
@PostMapping("/sign-out")
public ResponseEntity<BaseResponse<?>> signOut(Principal principal) {
authService.signOut(Util.getMemberId(principal));
return ApiResponseUtil.success(SUCCESS_SIGNOUT);
}

@Override
@DeleteMapping
public ResponseEntity<BaseResponse<?>> withDrawl(Principal principal) {
authService.withdraw(Util.getMemberId(principal));
Expand Down

0 comments on commit 77a8d79

Please sign in to comment.