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 intoopenid:masterfrom
Conversation
|
Codecov ReportAttention: 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 Sentry. |
| 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); |
|
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
@VisibleForTesting
static final String KEY_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 663
JsonUtil.putIfNotNull(json, KEY_ERROR_URI, errorUri);
JsonUtil.putIfNotNull(json, KEY_RESPONSE_JSON, responseJson);
return json;
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.