diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/client.js b/openid-connect-server-webapp/src/main/webapp/resources/js/client.js index a85e840a3..5b60dcf56 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/js/client.js +++ b/openid-connect-server-webapp/src/main/webapp/resources/js/client.js @@ -172,7 +172,7 @@ var ClientModel = Backbone.Model.extend({ var RegistrationTokenModel = Backbone.Model.extend({ idAttribute: 'clientId', - urlRoot: 'api/tokens/access/registration' + urlRoot: 'api/tokens/registration' }); var ClientCollection = Backbone.Collection.extend({ @@ -274,18 +274,25 @@ var ClientView = Backbone.View.extend({ $('#modalAlert .modal-body').html(_self.registrationTokenTemplate(savedModel)); + $('#modalAlert').modal({ + 'backdrop': 'static', + 'keyboard': true, + 'show': true + }); + }, error:function() { $('#modalAlert .modal-body').html('There was a problem loading the registration access token for this client.'); + + $('#modalAlert').modal({ + 'backdrop': 'static', + 'keyboard': true, + 'show': true + }); + } }); - $('#modalAlert').modal({ - 'backdrop': 'static', - 'keyboard': true, - 'show': true - }); - }, updateMatched:function() { diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ProviderTokenService.java b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ProviderTokenService.java index 64e9528cc..6c7e8d0e5 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ProviderTokenService.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ProviderTokenService.java @@ -478,7 +478,8 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi List allTokens = getAccessTokensForClient(client); for (OAuth2AccessTokenEntity token : allTokens) { - if (token.getScope().contains(SystemScopeService.REGISTRATION_TOKEN_SCOPE) && token.getScope().size() == 1) { + if ((token.getScope().contains(SystemScopeService.REGISTRATION_TOKEN_SCOPE) || token.getScope().contains(SystemScopeService.RESOURCE_TOKEN_SCOPE)) + && token.getScope().size() == 1) { // if it only has the registration scope, then it's a registration token return token; } diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/web/TokenAPI.java b/openid-connect-server/src/main/java/org/mitre/oauth2/web/TokenAPI.java index f51a65649..ed199d6db 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/web/TokenAPI.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/web/TokenAPI.java @@ -106,7 +106,7 @@ public class TokenAPI { } @PreAuthorize("hasRole('ROLE_ADMIN')") - @RequestMapping(value = "/access/client/{clientId}", method = RequestMethod.GET, produces = "application/json") + @RequestMapping(value = "/client/{clientId}", method = RequestMethod.GET, produces = "application/json") public String getAccessTokensByClientId(@PathVariable("clientId") String clientId, ModelMap m, Principal p) { ClientDetailsEntity client = clientService.loadClientByClientId(clientId); @@ -125,15 +125,21 @@ public class TokenAPI { } @PreAuthorize("hasRole('ROLE_ADMIN')") - @RequestMapping(value = "/access/registration/{clientId}", method = RequestMethod.GET, produces = "application/json") + @RequestMapping(value = "/registration/{clientId}", method = RequestMethod.GET, produces = "application/json") public String getRegistrationTokenByClientId(@PathVariable("clientId") String clientId, ModelMap m, Principal p) { ClientDetailsEntity client = clientService.loadClientByClientId(clientId); if (client != null) { OAuth2AccessTokenEntity token = tokenService.getRegistrationAccessTokenForClient(client); - m.put("entity", token); - return "tokenApiView"; + if (token != null) { + m.put("entity", token); + return "tokenApiView"; + } else { + m.put("code", HttpStatus.NOT_FOUND); + m.put("errorMessage", "No registration token could be found."); + return "jsonErrorView"; + } } else { // client not found m.put("code", HttpStatus.NOT_FOUND);