moved the API endpoints, made resource tokens accessible too
parent
34e90ff4f2
commit
f18f1701a3
|
@ -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() {
|
||||
|
|
|
@ -478,7 +478,8 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi
|
|||
List<OAuth2AccessTokenEntity> 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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue