Return bad request instead of unauthorized
This commit is contained in:
10
openapi.yml
10
openapi.yml
@ -18,6 +18,10 @@ servers:
|
|||||||
tags:
|
tags:
|
||||||
- name: hello
|
- name: hello
|
||||||
description: ""
|
description: ""
|
||||||
|
- name: token
|
||||||
|
description: ""
|
||||||
|
- name: signing-request
|
||||||
|
description: ""
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/hello:
|
/hello:
|
||||||
@ -51,6 +55,12 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/CreateSessionResponse"
|
$ref: "#/components/schemas/CreateSessionResponse"
|
||||||
|
400:
|
||||||
|
description: "Couldn't process request"
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/ErrorResponse"
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
@ -63,8 +63,8 @@ public class JwtRequestFilter extends OncePerRequestFilter {
|
|||||||
filterChain.doFilter(request, response);
|
filterChain.doFilter(request, response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
response.setContentType("application/json");
|
response.setContentType("application/json");
|
||||||
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
response.setStatus(HttpStatus.BAD_REQUEST.value());
|
||||||
response.getWriter().write(objectMapper.writeValueAsString(new ErrorResponse("Couldn't authenticate", HttpStatus.UNAUTHORIZED.value())));
|
response.getWriter().write(objectMapper.writeValueAsString(new ErrorResponse("Couldn't authenticate", HttpStatus.BAD_REQUEST.value())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user