Skip to content

Commit

Permalink
AUT-1273 Ory Hydra v2: OAuth2 errors can no longer be returned in the…
Browse files Browse the repository at this point in the history
… legacy error format
  • Loading branch information
aarmam authored and alarkvell committed Nov 28, 2023
1 parent 9ed5782 commit fac9dd8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ public class OidcErrorController {
@GetMapping(value = ERROR_OIDC_REQUEST_MAPPING)
public ModelAndView oidcError(
@RequestParam(name = "error") @Size(max = 50) String errorCode,
@RequestParam(name = "error_description", required = false, defaultValue = "not set") String errorDescription,
@RequestParam(name = "error_hint", required = false, defaultValue = "not set") String errorHint) {
@RequestParam(name = "error_description", required = false, defaultValue = "not set") String errorDescription) {

throw new SsoException(OIDC_ERRORS_MAP.getOrDefault(errorCode, ErrorCode.USER_OIDC_OTHER_ERROR),
"Oidc server error: code = %s, description = %s, hint = %s".formatted(errorCode, errorDescription, errorHint));
"Oidc server error: code = %s, description = %s".formatted(errorCode, errorDescription));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,51 @@ void oidcError_WhenInvalidOidcClientErrorCode_ThrowsInvalidOidcClientError() {
given()
.param("error", "invalid_client")
.param("error_description", "Invalid client error description")
.param("error_hint", "Invalid client error hint")
.when()
.get("/error/oidc")
.then()
.assertThat()
.statusCode(400)
.body("error", equalTo("USER_INVALID_OIDC_CLIENT"));

assertErrorIsLogged("SsoException: Oidc server error: code = invalid_client, description = Invalid client error description, hint = Invalid client error hint");
assertErrorIsLogged("SsoException: Oidc server error: code = invalid_client, description = Invalid client error description");
}

@Test
void oidcError_WhenInvalidOidcRequestErrorCode_ThrowsInvalidOidcRequestError() {
given()
.param("error", "invalid_request")
.param("error_description", "Invalid request error description")
.param("error_hint", "Invalid request error hint")
.when()
.get("/error/oidc")
.then()
.assertThat()
.statusCode(400)
.body("error", equalTo("USER_INVALID_OIDC_REQUEST"));

assertErrorIsLogged("SsoException: Oidc server error: code = invalid_request, description = Invalid request error description, hint = Invalid request error hint");
assertErrorIsLogged("SsoException: Oidc server error: code = invalid_request, description = Invalid request error description");
}

@Test
void oidcError_WhenUnknownErrorCode_ThrowsUserOidcOtherError() {
given()
.param("error", "unknown_error_code")
.param("error_description", "Error description")
.param("error_hint", "Error hint")
.when()
.get("/error/oidc")
.then()
.assertThat()
.statusCode(500)
.body("error", equalTo("USER_OIDC_OTHER_ERROR"));

assertErrorIsLogged("SsoException: Oidc server error: code = unknown_error_code, description = Error description, hint = Error hint");
assertErrorIsLogged("SsoException: Oidc server error: code = unknown_error_code, description = Error description");
}

@Test
void oidcError_WhenInvalidErrorCodeSize_ThrowsUserInputError() {
given()
.param("error", "x".repeat(51))
.param("error_description", "Error description")
.param("error_hint", "Error hint")
.when()
.get("/error/oidc")
.then()
Expand Down

0 comments on commit fac9dd8

Please sign in to comment.