diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/view/ExceptionAsJSONView.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/view/ExceptionAsJSONView.java index c58b25f67..03234edf9 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/view/ExceptionAsJSONView.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/view/ExceptionAsJSONView.java @@ -21,8 +21,10 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.http.HttpResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.web.servlet.view.AbstractView; @@ -50,6 +52,8 @@ public class ExceptionAsJSONView extends AbstractView { response.setContentType("application/json"); + response.setStatus(HttpStatus.BAD_REQUEST.value()); + final JsonObject jsonObject = new JsonObject(); Object ex = model.get("exception"); diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java index c53c1783c..a9fd8e50f 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java @@ -26,6 +26,7 @@ import org.mitre.openid.connect.service.UserInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.security.oauth2.common.exceptions.InvalidScopeException; import org.springframework.security.oauth2.provider.OAuth2Authentication; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -64,8 +65,9 @@ public class UserInfoEndpoint { /** * Get information about the user as specified in the accessToken->idToken included in this request * - * @throws UsernameNotFoundException if the user does not exist or cannot be found + * @throws UserNotFoundException if the user does not exist or cannot be found * @throws UnknownUserInfoSchemaException if an unknown schema is used + * @throws InvalidScopeException if the oauth2 token doesn't have the "openid" scope */ @PreAuthorize("hasRole('ROLE_USER') and #oauth2.hasScope('openid')") @RequestMapping(value="/userinfo", method= {RequestMethod.GET, RequestMethod.POST}) diff --git a/openid-connect-server/src/main/webapp/WEB-INF/application-context.xml b/openid-connect-server/src/main/webapp/WEB-INF/application-context.xml index d33933597..a9c4307b9 100644 --- a/openid-connect-server/src/main/webapp/WEB-INF/application-context.xml +++ b/openid-connect-server/src/main/webapp/WEB-INF/application-context.xml @@ -177,6 +177,7 @@ exceptionAsJSONView exceptionAsJSONView exceptionAsJSONView + exceptionAsJSONView exception/usernotfound