Uh oh!
There was an error while loading. Please reload this page.
Expose error response json in case extra parameters are given. - #885
Expose error response json in case extra parameters are given.#885doreaimon wants to merge 2 commits into
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## master #885 +/- ##
=========================================
Coverage 82.92% 82.93% Complexity 532 532 =========================================
Files 46 46 Lines 2642 2643 +1 Branches 264 264 =========================================
+ Hits 2191 2192 +1
Misses 351 351 Partials 100 100 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| private static AuthorizationException generalEx(int code, @Nullable String errorDescription) { | ||
| return new AuthorizationException( | ||
| TYPE_GENERAL_ERROR, code, null, errorDescription, null, null); | ||
| TYPE_GENERAL_ERROR, code, null, errorDescription, null, null, null); |
| private static AuthorizationException generalEx(int code, @Nullable String errorDescription) { | ||
| return new AuthorizationException( | ||
| TYPE_GENERAL_ERROR, code, null, errorDescription, null, null); | ||
| TYPE_GENERAL_ERROR, code, null, errorDescription, null, null, null); |
| private static AuthorizationException generalEx(int code, @Nullable String errorDescription) { | ||
| return new AuthorizationException( | ||
| TYPE_GENERAL_ERROR, code, null, errorDescription, null, null); | ||
| TYPE_GENERAL_ERROR, code, null, errorDescription, null, null, null); |
| private static AuthorizationException generalEx(int code, @Nullable String errorDescription) { | ||
| return new AuthorizationException( | ||
| TYPE_GENERAL_ERROR, code, null, errorDescription, null, null); | ||
| TYPE_GENERAL_ERROR, code, null, errorDescription, null, null, null); |
pcuriel
commented
Feb 8, 2024
Very interested in this as well. In this case, due to a Keycloak custom Authenticator returning additional non-standard fields for some error cases, which there is no way to access with the current implementation of |
| @Nullable | ||
| public final JSONObject responseJson; | ||
| /** |
There was a problem hiding this comment.
Add corresponding field for serialization
// Line 142@VisibleForTestingstaticfinalStringKEY_RESPONSE_JSON = "responseJson";| JsonUtil.getStringIfDefined(json, KEY_ERROR), | ||
| JsonUtil.getStringIfDefined(json, KEY_ERROR_DESCRIPTION), | ||
| JsonUtil.getUriIfDefined(json, KEY_ERROR_URI), | ||
| json, |
There was a problem hiding this comment.
| json, | |
| JsonUtil.getJsonObjectIfDefined(json, KEY_RESPONSE_JSON), |
And toJson is missing the reponseJson field serialization:
// Line 663JsonUtil.putIfNotNull(json, KEY_ERROR_URI, errorUri);
JsonUtil.putIfNotNull(json, KEY_RESPONSE_JSON, responseJson);
returnjson;
Checklist
Motivation and Context
We have found that some servers will return non-standard parameters along with the standard ones in their error responses, and we see a need for getting access to those parameters. To facilitate this, we would like to pass back the full original error response
JSONObjectalong in the token request callback in theAuthorizationException.Description
We held onto the original error response
JSONObjectand added it as an optional field in theAuthorizationExceptionthat is passed to the token request callback.