|
|
@ -30,6 +30,9 @@ import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.google.common.base.Strings;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* OpenID Connect UserInfo endpoint, as specified in Standard sec 5 and Messages sec 2.4.
|
|
|
|
* OpenID Connect UserInfo endpoint, as specified in Standard sec 5 and Messages sec 2.4.
|
|
|
@ -50,7 +53,7 @@ public class UserInfoEndpoint {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PreAuthorize("hasRole('ROLE_USER') and #oauth2.hasScope('openid')")
|
|
|
|
@PreAuthorize("hasRole('ROLE_USER') and #oauth2.hasScope('openid')")
|
|
|
|
@RequestMapping(value="/userinfo", method= {RequestMethod.GET, RequestMethod.POST}, produces = "application/json")
|
|
|
|
@RequestMapping(value="/userinfo", method= {RequestMethod.GET, RequestMethod.POST}, produces = "application/json")
|
|
|
|
public String getInfo(Principal p, Model model) {
|
|
|
|
public String getInfo(@RequestParam(value="claims", required=false) String claimsRequestJsonString, Principal p, Model model) {
|
|
|
|
|
|
|
|
|
|
|
|
if (p == null) {
|
|
|
|
if (p == null) {
|
|
|
|
logger.error("getInfo failed; no principal. Requester is not authorized.");
|
|
|
|
logger.error("getInfo failed; no principal. Requester is not authorized.");
|
|
|
@ -66,6 +69,10 @@ public class UserInfoEndpoint {
|
|
|
|
model.addAttribute("code", HttpStatus.NOT_FOUND);
|
|
|
|
model.addAttribute("code", HttpStatus.NOT_FOUND);
|
|
|
|
return "httpCodeView";
|
|
|
|
return "httpCodeView";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Strings.isNullOrEmpty(claimsRequestJsonString)) {
|
|
|
|
|
|
|
|
model.addAttribute("claimsRequest", claimsRequestJsonString);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (p instanceof OAuth2Authentication) {
|
|
|
|
if (p instanceof OAuth2Authentication) {
|
|
|
|
OAuth2Authentication authentication = (OAuth2Authentication)p;
|
|
|
|
OAuth2Authentication authentication = (OAuth2Authentication)p;
|
|
|
|