updated registration URI, addresses #321

pull/338/head
Justin Richer 2013-05-10 11:54:48 -07:00
parent cc9eea5b3d
commit 545ddace95
2 changed files with 16 additions and 3 deletions

View File

@ -66,8 +66,7 @@ public class ClientInformationResponseView extends AbstractView {
code = HttpStatus.OK; code = HttpStatus.OK;
} }
// TODO: urlencode the client id for safety? String uri = (String)model.get("uri"); //request.getRequestURL() + "/" + c.getClientId();
String uri = request.getRequestURL() + "/" + c.getClientId();
JsonObject o = ClientDetailsEntityJsonProcessor.serialize(c, token, uri); JsonObject o = ClientDetailsEntityJsonProcessor.serialize(c, token, uri);
try { try {

View File

@ -20,6 +20,8 @@ package org.mitre.openid.connect.web;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.client.utils.URLEncodedUtils;
import org.mitre.oauth2.model.ClientDetailsEntity; import org.mitre.oauth2.model.ClientDetailsEntity;
import org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod; import org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod;
import org.mitre.oauth2.model.OAuth2AccessTokenEntity; import org.mitre.oauth2.model.OAuth2AccessTokenEntity;
@ -28,6 +30,7 @@ import org.mitre.oauth2.service.ClientDetailsEntityService;
import org.mitre.oauth2.service.OAuth2TokenEntityService; import org.mitre.oauth2.service.OAuth2TokenEntityService;
import org.mitre.oauth2.service.SystemScopeService; import org.mitre.oauth2.service.SystemScopeService;
import org.mitre.openid.connect.ClientDetailsEntityJsonProcessor; import org.mitre.openid.connect.ClientDetailsEntityJsonProcessor;
import org.mitre.openid.connect.config.ConfigurationPropertiesBean;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -59,6 +62,9 @@ public class ClientDynamicRegistrationEndpoint {
@Autowired @Autowired
private SystemScopeService scopeService; private SystemScopeService scopeService;
@Autowired
private ConfigurationPropertiesBean config;
private static Logger logger = LoggerFactory.getLogger(ClientDynamicRegistrationEndpoint.class); private static Logger logger = LoggerFactory.getLogger(ClientDynamicRegistrationEndpoint.class);
@ -148,7 +154,9 @@ public class ClientDynamicRegistrationEndpoint {
m.addAttribute("client", savedClient); m.addAttribute("client", savedClient);
m.addAttribute("code", HttpStatus.CREATED); // http 201 m.addAttribute("code", HttpStatus.CREATED); // http 201
m.addAttribute("token", token); m.addAttribute("token", token);
// TODO: urlencode the client id for safety?
m.addAttribute("uri", config.getIssuer() + "register/" + savedClient.getClientId());
return "clientInformationResponseView"; return "clientInformationResponseView";
} else { } else {
// didn't parse, this is a bad request // didn't parse, this is a bad request
@ -184,6 +192,8 @@ public class ClientDynamicRegistrationEndpoint {
m.addAttribute("client", client); m.addAttribute("client", client);
m.addAttribute("code", HttpStatus.OK); // http 200 m.addAttribute("code", HttpStatus.OK); // http 200
m.addAttribute("token", token); m.addAttribute("token", token);
// TODO: urlencode the client id for safety?
m.addAttribute("uri", config.getIssuer() + "register/" + client.getClientId());
return "clientInformationResponseView"; return "clientInformationResponseView";
} else { } else {
@ -255,6 +265,8 @@ public class ClientDynamicRegistrationEndpoint {
m.addAttribute("client", savedClient); m.addAttribute("client", savedClient);
m.addAttribute("code", HttpStatus.OK); // http 200 m.addAttribute("code", HttpStatus.OK); // http 200
m.addAttribute("token", token); m.addAttribute("token", token);
// TODO: urlencode the client id for safety?
m.addAttribute("uri", config.getIssuer() + "register/" + savedClient.getClientId());
return "clientInformationResponseView"; return "clientInformationResponseView";
} else { } else {
@ -292,6 +304,8 @@ public class ClientDynamicRegistrationEndpoint {
m.addAttribute("client", client); m.addAttribute("client", client);
m.addAttribute("code", HttpStatus.OK); // http 200 m.addAttribute("code", HttpStatus.OK); // http 200
m.addAttribute("token", token); m.addAttribute("token", token);
// TODO: urlencode the client id for safety?
m.addAttribute("uri", config.getIssuer() + "register/" + client.getClientId());
return "clientInformationResponseView"; return "clientInformationResponseView";
} else { } else {