-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from K-Hackathon-Fledge/34-refactoring-token-a…
…uth-refactoring 34 refactoring token auth refactoring
- Loading branch information
Showing
24 changed files
with
368 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/com/fledge/fledgeserver/auth/controller/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.fledge.fledgeserver.auth.controller; | ||
|
||
import com.fledge.fledgeserver.auth.dto.TokenResponse; | ||
import com.fledge.fledgeserver.auth.service.AuthService; | ||
import com.fledge.fledgeserver.response.ApiResponse; | ||
import com.fledge.fledgeserver.response.SuccessStatus; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
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.RestController; | ||
|
||
@Tag(name = "인증 관련 API", description = "인증과 관련된 API") | ||
@Slf4j | ||
@RestController | ||
@RequestMapping("/api/v1/auth") | ||
@RequiredArgsConstructor | ||
public class AuthController { | ||
|
||
private final AuthService authService; | ||
|
||
@Operation(summary = "로그아웃", description = "현재 사용자를 로그아웃 합니다.") | ||
@PostMapping("/logout") | ||
public ResponseEntity<ApiResponse<String>> logout(HttpServletRequest request, HttpServletResponse response) { | ||
authService.logout(request, response); | ||
return ApiResponse.success(SuccessStatus.LOGOUT_SUCCESS); | ||
} | ||
|
||
@Operation(summary = "토큰 재발급", description = "만료된 JWT 토큰을 재발급 합니다.") | ||
@GetMapping(value = "/tokenRefresh", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<ApiResponse<TokenResponse>> refresh() { | ||
TokenResponse tokenResponse = authService.refreshToken(); | ||
return ApiResponse.success(SuccessStatus.TOKEN_REFRESH_SUCCESS, tokenResponse); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/fledge/fledgeserver/auth/dto/TokenResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.fledge.fledgeserver.auth.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.*; | ||
|
||
@Data | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
@Builder | ||
public class TokenResponse { | ||
|
||
@Schema(description = "액세스 토큰", example = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...") | ||
private String accessToken; | ||
|
||
@Schema(description = "리프레시 토큰", example = "dGhpc2lzYXJlZnJlc2h0b2tlbg==") | ||
private String refreshToken; | ||
|
||
} |
59 changes: 0 additions & 59 deletions
59
src/main/java/com/fledge/fledgeserver/auth/filter/TokenAuthenticationFilter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/com/fledge/fledgeserver/auth/jwt/JwtConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.fledge.fledgeserver.auth.jwt; | ||
|
||
public class JwtConstants { | ||
public static final String BEARER_PREFIX = "Bearer "; | ||
public static final String AUTHORITIES = "role"; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.