Gam-develop / gam-server

GAM-SERVER
4 stars 2 forks source link

[FIX] 온보딩 security 이슈 #111

Closed GaHee99 closed 9 months ago

GaHee99 commented 10 months ago

🧐 설명!

아래 클래스에서 막히는 것 같은데, 단순히 if-else로 막아서그런듯.. `

@Component
@RequiredArgsConstructor
public class CustomAccessDeniedHandler implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException accessDeniedException) throws IOException {
        val objectMapper = new ObjectMapper();
        val exceptionMessage = determineExceptionMessage(httpServletRequest.getRequestURI());
        val jsonResponse = objectMapper.writeValueAsString(
                    ApiResponse.fail(exceptionMessage)
                );

        httpServletResponse.setStatus(HttpStatus.FORBIDDEN.value());
        httpServletResponse.setContentType(MediaType.APPLICATION_JSON_VALUE);
        httpServletResponse.setCharacterEncoding("UTF-8");
        httpServletResponse.getWriter().write(jsonResponse);
    }

    private String determineExceptionMessage(String requestUri) {
        if (requestUri.contains("admin")) {
            return ExceptionMessage.NOT_ADMIN_USER.getMessage();
        } else {
            return ExceptionMessage.PROFILE_UNCOMPLETED_USER.getMessage();
        }
    }
}

`

그런데, security filterchain에서 로직 확인 필요..   스크린샷 2024-01-09 오후 2 47 56