Skip to content

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

@jongmee

Description

@jongmee

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로 넘길텐데 왜 이런 일이 ???

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions