moved the API endpoints, made resource tokens accessible too
parent
cf198cccc2
commit
9e88a62479
|
@ -172,7 +172,7 @@ var ClientModel = Backbone.Model.extend({
|
||||||
|
|
||||||
var RegistrationTokenModel = Backbone.Model.extend({
|
var RegistrationTokenModel = Backbone.Model.extend({
|
||||||
idAttribute: 'clientId',
|
idAttribute: 'clientId',
|
||||||
urlRoot: 'api/tokens/access/registration'
|
urlRoot: 'api/tokens/registration'
|
||||||
});
|
});
|
||||||
|
|
||||||
var ClientCollection = Backbone.Collection.extend({
|
var ClientCollection = Backbone.Collection.extend({
|
||||||
|
@ -274,16 +274,23 @@ var ClientView = Backbone.View.extend({
|
||||||
|
|
||||||
$('#modalAlert .modal-body').html(_self.registrationTokenTemplate(savedModel));
|
$('#modalAlert .modal-body').html(_self.registrationTokenTemplate(savedModel));
|
||||||
|
|
||||||
|
$('#modalAlert').modal({
|
||||||
|
'backdrop': 'static',
|
||||||
|
'keyboard': true,
|
||||||
|
'show': true
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
error:function() {
|
error:function() {
|
||||||
$('#modalAlert .modal-body').html('There was a problem loading the registration access token for this client.');
|
$('#modalAlert .modal-body').html('There was a problem loading the registration access token for this client.');
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#modalAlert').modal({
|
$('#modalAlert').modal({
|
||||||
'backdrop': 'static',
|
'backdrop': 'static',
|
||||||
'keyboard': true,
|
'keyboard': true,
|
||||||
'show': true
|
'show': true
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
@ -478,7 +478,8 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi
|
||||||
List<OAuth2AccessTokenEntity> allTokens = getAccessTokensForClient(client);
|
List<OAuth2AccessTokenEntity> allTokens = getAccessTokensForClient(client);
|
||||||
|
|
||||||
for (OAuth2AccessTokenEntity token : allTokens) {
|
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
|
// if it only has the registration scope, then it's a registration token
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class TokenAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
@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) {
|
public String getAccessTokensByClientId(@PathVariable("clientId") String clientId, ModelMap m, Principal p) {
|
||||||
|
|
||||||
ClientDetailsEntity client = clientService.loadClientByClientId(clientId);
|
ClientDetailsEntity client = clientService.loadClientByClientId(clientId);
|
||||||
|
@ -125,15 +125,21 @@ public class TokenAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
@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) {
|
public String getRegistrationTokenByClientId(@PathVariable("clientId") String clientId, ModelMap m, Principal p) {
|
||||||
|
|
||||||
ClientDetailsEntity client = clientService.loadClientByClientId(clientId);
|
ClientDetailsEntity client = clientService.loadClientByClientId(clientId);
|
||||||
|
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
OAuth2AccessTokenEntity token = tokenService.getRegistrationAccessTokenForClient(client);
|
OAuth2AccessTokenEntity token = tokenService.getRegistrationAccessTokenForClient(client);
|
||||||
m.put("entity", token);
|
if (token != null) {
|
||||||
return "tokenApiView";
|
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 {
|
} else {
|
||||||
// client not found
|
// client not found
|
||||||
m.put("code", HttpStatus.NOT_FOUND);
|
m.put("code", HttpStatus.NOT_FOUND);
|
||||||
|
|
Loading…
Reference in New Issue