-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FIX] Security Config 로직 수정
- Loading branch information
Showing
11 changed files
with
102 additions
and
101 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
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
30 changes: 0 additions & 30 deletions
30
src/main/java/com/tiki/server/auth/exception/handler/CustomAccessDeniedHandler.java
This file was deleted.
Oops, something went wrong.
22 changes: 16 additions & 6 deletions
22
...in/java/com/tiki/server/auth/exception/handler/CustomAuthenticationEntryPointHandler.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 |
---|---|---|
@@ -1,33 +1,43 @@ | ||
package com.tiki.server.auth.exception.handler; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.tiki.server.auth.info.AuthenticationResponse; | ||
import com.tiki.server.auth.message.ErrorCode; | ||
import com.tiki.server.common.dto.ErrorResponse; | ||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import lombok.val; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.security.core.AuthenticationException; | ||
import org.springframework.security.web.AuthenticationEntryPoint; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.io.IOException; | ||
|
||
import static com.tiki.server.auth.message.ErrorCode.UNAUTHENTICATED_USER; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class CustomAuthenticationEntryPointHandler implements AuthenticationEntryPoint { | ||
|
||
private final AuthenticationResponse authenticationResponse; | ||
private final ObjectMapper objectMapper; | ||
|
||
@Override | ||
public void commence( | ||
HttpServletRequest request, | ||
HttpServletResponse response, | ||
AuthenticationException authException | ||
) throws IOException { | ||
authenticationResponse.makeFailureResponse(response, UNAUTHENTICATED_USER); | ||
log.info("-EntryPoint-"); | ||
setResponse(response, ErrorCode.UNAUTHENTICATED_USER.getMessage()); | ||
} | ||
|
||
private void setResponse(HttpServletResponse response, String errorMessage) throws IOException { | ||
response.setContentType(MediaType.APPLICATION_JSON_VALUE); | ||
response.setCharacterEncoding("UTF-8"); | ||
response.setStatus(HttpStatus.UNAUTHORIZED.value()); | ||
val writer = response.getWriter(); | ||
writer.write(objectMapper.writeValueAsString(ErrorResponse.of(errorMessage))); | ||
} | ||
} |
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
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
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
9 changes: 0 additions & 9 deletions
9
src/main/java/com/tiki/server/auth/jwt/JwtValidationType.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
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
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