added in checks to blacklist service upon client registration and update
parent
7a6c96a759
commit
5b0c17c5de
|
@ -68,7 +68,13 @@ public class DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEnt
|
||||||
@Override
|
@Override
|
||||||
public ClientDetailsEntity saveNewClient(ClientDetailsEntity client) {
|
public ClientDetailsEntity saveNewClient(ClientDetailsEntity client) {
|
||||||
if (client.getId() != null) { // if it's not null, it's already been saved, this is an error
|
if (client.getId() != null) { // if it's not null, it's already been saved, this is an error
|
||||||
return null; // TODO: throw exception?
|
throw new IllegalArgumentException("Tried to save a new client with an existing ID: " + client.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String uri : client.getRegisteredRedirectUri()) {
|
||||||
|
if (blacklistedSiteService.isBlacklisted(uri)) {
|
||||||
|
throw new IllegalArgumentException("Client URI is blacklisted: " + uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign a random clientid if it's empty
|
// assign a random clientid if it's empty
|
||||||
|
@ -141,6 +147,13 @@ public class DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEnt
|
||||||
@Override
|
@Override
|
||||||
public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException {
|
public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException {
|
||||||
if (oldClient != null && newClient != null) {
|
if (oldClient != null && newClient != null) {
|
||||||
|
|
||||||
|
for (String uri : newClient.getRegisteredRedirectUri()) {
|
||||||
|
if (blacklistedSiteService.isBlacklisted(uri)) {
|
||||||
|
throw new IllegalArgumentException("Client URI is blacklisted: " + uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return clientRepository.updateClient(oldClient.getId(), newClient);
|
return clientRepository.updateClient(oldClient.getId(), newClient);
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Neither old client or new client can be null!");
|
throw new IllegalArgumentException("Neither old client or new client can be null!");
|
||||||
|
|
Loading…
Reference in New Issue