Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@
import com.Timo.Timo.global.auth.handler.AuthErrorResponseWriter;
import com.Timo.Timo.global.auth.service.AuthCodeService;
import com.Timo.Timo.global.exception.code.ErrorCode;
import com.Timo.Timo.global.exception.dto.ErrorDto;
import com.Timo.Timo.global.jwt.provider.JwtTokenProvider;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "Auth", description = "์ธ์ฆ ๊ด€๋ จ API")
@RestController
@RequestMapping("/api/auth")
@RequiredArgsConstructor
Expand All @@ -26,8 +35,32 @@ public class AuthController {
private final AuthErrorResponseWriter authErrorResponseWriter;
private final ObjectMapper objectMapper;

@GetMapping("/token")
@Operation(
summary = "AccessToken ๋ฐœ๊ธ‰",
description = "์†Œ์…œ ๋กœ๊ทธ์ธ ์„ฑ๊ณต ์‹œ ๋ฐœ๊ธ‰๋œ 1ํšŒ์šฉ ์ธ์ฆ ์ฝ”๋“œ(code)๋ฅผ ํ†ตํ•ด AccessToken์„ ๋ฐœ๊ธ‰ํ•ฉ๋‹ˆ๋‹ค. "
+ "์ธ์ฆ ์ฝ”๋“œ๋Š” 1ํšŒ ์‚ฌ์šฉ ํ›„ ์ฆ‰์‹œ ๋งŒ๋ฃŒ๋ฉ๋‹ˆ๋‹ค."
)
@ApiResponses({
@ApiResponse(
responseCode = "200",
description = "AccessToken ๋ฐœ๊ธ‰ ์„ฑ๊ณต",
content = @Content(
mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(example = "{\"accessToken\": \"eyJhbGciOiJIUzI1NiJ9...\"}")
)
),
@ApiResponse(
responseCode = "401",
description = "์œ ํšจํ•˜์ง€ ์•Š๊ฑฐ๋‚˜ ๋งŒ๋ฃŒ๋œ ์ธ์ฆ ์ฝ”๋“œ",
content = @Content(
mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorDto.class)
)
)
})
@PostMapping("/token")
public void token(
@Parameter(description = "์†Œ์…œ ๋กœ๊ทธ์ธ ์„ฑ๊ณต ์‹œ ๋ฐœ๊ธ‰๋œ 1ํšŒ์šฉ ์ธ์ฆ ์ฝ”๋“œ", required = true)
@RequestParam String code,
HttpServletRequest request,
HttpServletResponse response
Expand Down
Loading