[java-idp-oidc] branch main updated: JOIDC-128 - Support OAuth authorization requests
Henri Mikkonen
henri.mikkonen at iki.fi
Wed Oct 19 09:15:48 UTC 2022
This is an automated email from the git hooks/post-receive script.
hjmikkon pushed a commit to branch main
in repository java-idp-oidc.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-oidc.git;a=commit;h=ab96a19a53512967aae89da87a463a333fd191e1
The following commit(s) were added to refs/heads/main by this push:
new ab96a19a JOIDC-128 - Support OAuth authorization requests
ab96a19a is described below
commit ab96a19a53512967aae89da87a463a333fd191e1
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Wed Oct 19 12:15:01 2022 +0300
JOIDC-128 - Support OAuth authorization requests
https://shibboleth.atlassian.net/browse/JOIDC-128
Log OAuth response messages properly for the PROTOCOL_MESSAGE appender.
---
.../plugin/oidc/op/encoding/impl/ResponseUtil.java | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/encoding/impl/ResponseUtil.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/encoding/impl/ResponseUtil.java
index 4b0f52c9..bf8813de 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/encoding/impl/ResponseUtil.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/encoding/impl/ResponseUtil.java
@@ -28,6 +28,9 @@ import javax.servlet.http.HttpServletResponse;
import com.google.common.base.MoreObjects;
import com.nimbusds.oauth2.sdk.AccessTokenResponse;
+import com.nimbusds.oauth2.sdk.AuthorizationErrorResponse;
+import com.nimbusds.oauth2.sdk.AuthorizationResponse;
+import com.nimbusds.oauth2.sdk.AuthorizationSuccessResponse;
import com.nimbusds.oauth2.sdk.ErrorObject;
import com.nimbusds.oauth2.sdk.ErrorResponse;
import com.nimbusds.oauth2.sdk.Response;
@@ -132,6 +135,8 @@ public final class ResponseUtil {
}
if (response instanceof AuthenticationResponse) {
return getProtocolMessageForAuthenticationResponse((AuthenticationResponse) response);
+ } else if (response instanceof AuthorizationResponse) {
+ return getProtocolMessageForAuthorizationResponse((AuthorizationResponse) response);
} else if (response instanceof OIDCClientInformationResponse) {
return getProtocolMessageForRegistrationResponse((OIDCClientInformationResponse) response);
} else if (response instanceof TokenResponse) {
@@ -193,6 +198,40 @@ public final class ResponseUtil {
}
}
+ /**
+ * Helper method for getting protocol message for OAuth authorization response.
+ *
+ * @param response The response message
+ * @return The response message specific log message
+ */
+ @Nullable public static String getProtocolMessageForAuthorizationResponse(
+ @Nonnull final AuthorizationResponse response) {
+ if (response.indicatesSuccess()) {
+ final AuthorizationSuccessResponse successResponse = response.toSuccessResponse();
+ return MoreObjects.toStringHelper(successResponse).omitNullValues()
+ .add("accessToken", RequestUtil.getAccessTokenLog(successResponse.getAccessToken()))
+ .add("authorizationCode", successResponse.getAuthorizationCode())
+ .add("issuer", successResponse.getIssuer())
+ .add("jwtResponse", successResponse.getJWTResponse() == null ?
+ null : successResponse.getJWTResponse().serialize())
+ .add("redirectionURI", successResponse.getRedirectionURI())
+ .add("responseMode", successResponse.getResponseMode())
+ .add("state", successResponse.getState())
+ .toString();
+ } else {
+ final AuthorizationErrorResponse errorResponse = response.toErrorResponse();
+ return MoreObjects.toStringHelper(errorResponse).omitNullValues()
+ .add("errorObject", getProtocolMessageForErrorObject(errorResponse.getErrorObject()))
+ .add("issuer", errorResponse.getIssuer())
+ .add("jwtResponse", errorResponse.getJWTResponse() == null ?
+ null : errorResponse.getJWTResponse().serialize())
+ .add("redirectionURI", errorResponse.getRedirectionURI())
+ .add("responseMode", errorResponse.getResponseMode())
+ .add("state", errorResponse.getState())
+ .toString();
+ }
+ }
+
/**
* Helper method for getting protocol message for OIDC registration response.
*
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list