Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 잘못된 method로 요청시 405 대신 401을 반환 #29

Open
jongmee opened this issue Aug 18, 2024 · 0 comments
Open

fix: 잘못된 method로 요청시 405 대신 401을 반환 #29

jongmee opened this issue Aug 18, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@jongmee
Copy link
Contributor

jongmee commented Aug 18, 2024

Problem 🐞

특정 api(GET applications/evaluation)의 method만 405 반환을 하지 않고 (HttpRequestMethodNotSupportedException가 발생하지 않고) HandlerMethodArgumentResolver까지 요청이 전달돼 401이 반환된다. 해당 401 에러는 ArgumentResolver에서 처리한 로직이다. (심지어 권한이 없는 사용자로 요청하지도 않았음

Request method:	GET
Request URI:	http://localhost:53708/applications/evaluation
Proxy:			<none>
Request params:	<none>
Query params:	<none>
Form params:	<none>
Path params:	<none>
Headers:		Authorization=Bearer dummy token
			Accept=*/*
			Content-Type=application/json
Cookies:		<none>
Multiparts:		<none>
Body:
{
    "passApplicationIds": [
        1
    ]
}
HTTP/1.1 401 
Content-Type: application/json
Transfer-Encoding: chunked
Date: Sun, 18 Aug 2024 05:19:57 GMT
Keep-Alive: timeout=60
Connection: keep-alive

{
    "message": "권한이 없는 사용자입니다."
}

아래는 해당 api

    @PostMapping("/evaluation")
    public ResponseEntity<Void> evaluate(@AdminAuthentication LoginUser loginUser,
                                         @RequestBody EvaluationRequest request) {
        applicationService.decideOutcome(request, loginUser.userId());
        return ResponseEntity.ok().build();
    }

Progress 🐢

크리티컬한 오류는 아니므로 후순위로 미룬다. 하지만 궁금하다.

Help ❗️

스프링 시큐리티를 쓰는 것도 아닌데 왜 .. ? DispatcherServlet에서 method mapping하고 argument resolver로 넘길텐데 왜 이런 일이 ???

@jongmee jongmee added the bug Something isn't working label Aug 18, 2024
@jongmee jongmee self-assigned this Aug 18, 2024
@jongmee jongmee changed the title fix: 잘못된 method로 요청시 405 반환 대신 401을 반환 fix: 잘못된 method로 요청시 405 대신 401을 반환 Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant