mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
08.20.2016 aeed3c534c0a52f3fbf525573715349fb187316a
OPENDJ-3096 Fix incorrect response status code

In the case where rest2ldap were not able to resolve the authzIdTemplate with an access token we were returned a 403 (forbidden) error response.
As Matt pointed out, this is not a client application here so we now return a 500 (internal server error) with no error message.
2 files modified
6 ■■■■■ changed files
opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/authz/Authorizations.java 5 ●●●●● patch | view | raw | blame | history
opendj-rest2ldap/src/main/resources/org/forgerock/opendj/rest2ldap/rest2ldap.properties 1 ●●●● patch | view | raw | blame | history
opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/authz/Authorizations.java
@@ -267,9 +267,8 @@
                try {
                    authz.put(template.getSecurityContextID(), template.formatAsAuthzId(token.asJsonValue()));
                } catch (final IllegalArgumentException e) {
                    return newResultPromise(new Response().setStatus(Status.FORBIDDEN)
                                                          .setCause(e)
                                                          .setEntity(ERR_AUTHZID_DECODER_RESPONSE.get().toString()));
                    return newResultPromise(new Response().setStatus(Status.INTERNAL_SERVER_ERROR)
                                                          .setCause(e));
                }
                final Context securityContext = new SecurityContext(context, token.getToken(), authz);
                return next.handle(securityContext, request);
opendj-rest2ldap/src/main/resources/org/forgerock/opendj/rest2ldap/rest2ldap.properties
@@ -41,7 +41,6 @@
 security principal '%s' could not be determined
ERR_AUTHZID_DECODER_PRINCIPAL_INVALID_DATA_TYPE_18=The request could not be authorized because the required \
 security principal '%s' had an invalid data type
ERR_AUTHZID_DECODER_RESPONSE_19=Invalid configuration
ERR_RESOLVING_AUTHZID_TEMPLATE_20=Unable to resolve oauthzid template placeholders for access token '%s': '%s'
# Runtime errors > OAuth2 > CTS Resolver
ERR_OAUTH2_CTS_INVALID_TOKEN_TYPE_21=The token '%s' must be an access token, but it is a '%s'