Skip to content

Commit

Permalink
Merge pull request #197 from Akila94/par-response-code-fix
Browse files Browse the repository at this point in the history
Fix issue of PAR response returning wrong error code when mandatory params not present in the client assertion
  • Loading branch information
imesh94 authored Nov 25, 2024
2 parents 2cf01e4 + 62e75e1 commit eeb0001
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ public Response parPost(@Context HttpServletRequest request, @Context HttpServle
OAuthClientAuthnContext clientAuthnContext = (OAuthClientAuthnContext)
request.getAttribute(CLIENT_AUTHENTICATION_CONTEXT);

// Check if the client authentication is successful
if (!clientAuthnContext.isAuthenticated()) {
// create error response
PushAuthErrorResponse errorResponse = pushAuthRequestValidator
.createErrorResponse(HttpServletResponse.SC_UNAUTHORIZED,
clientAuthnContext.getErrorCode(), clientAuthnContext.getErrorMessage());
return Response.status(errorResponse.getHttpStatusCode())
.entity(errorResponse.getPayload()).build();
}

try {
paramMap = pushAuthRequestValidator.validateParams(request, (Map<String, List<String>>) parameterMap);
} catch (PushAuthRequestValidatorException exception) {
Expand All @@ -113,7 +103,17 @@ public Response parPost(@Context HttpServletRequest request, @Context HttpServle
.createErrorResponse(exception.getHttpStatusCode(), exception.getErrorCode(),
exception.getErrorDescription());
return Response.status(errorResponse.getHttpStatusCode() != 0 ?
errorResponse.getHttpStatusCode() : exception.getHttpStatusCode())
errorResponse.getHttpStatusCode() : exception.getHttpStatusCode())
.entity(errorResponse.getPayload()).build();
}

// Check if the client authentication is successful
if (!clientAuthnContext.isAuthenticated()) {
// create error response
PushAuthErrorResponse errorResponse = pushAuthRequestValidator
.createErrorResponse(HttpServletResponse.SC_UNAUTHORIZED,
clientAuthnContext.getErrorCode(), clientAuthnContext.getErrorMessage());
return Response.status(errorResponse.getHttpStatusCode())
.entity(errorResponse.getPayload()).build();
}

Expand Down

0 comments on commit eeb0001

Please sign in to comment.