Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 705 iam admins should be able to suspend clients #715

Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
09b64b0
Add client status component
garaimanoj Feb 26, 2024
ba1ca19
Remove debug code
garaimanoj Feb 29, 2024
7ac60e8
Add API and service methods to change client status
garaimanoj Mar 1, 2024
02bc665
Add new columns for client status and test data
garaimanoj Mar 1, 2024
6fdae28
Handle API call from frontend and convert client entity
garaimanoj Mar 1, 2024
3f31509
Set status as active for new client
garaimanoj Mar 12, 2024
77c21ce
Add suspended label next to client name
garaimanoj Mar 12, 2024
2956e7f
Test client status change
garaimanoj Mar 12, 2024
92baf1a
Merge branch 'develop' into issue-705-iam-admins-should-be-able-to-su…
garaimanoj Mar 12, 2024
79e2c50
Remove whitespace difference
garaimanoj Mar 12, 2024
5881a8f
Rename file to avoid duplicate name and set test data
garaimanoj Mar 13, 2024
b18c51c
Update mitreid version
garaimanoj Mar 14, 2024
50308e4
Alter client details table
garaimanoj Mar 15, 2024
7bae731
Add default date to status changed on
garaimanoj Mar 15, 2024
1739c0c
Fix JavaScript function undefined error
garaimanoj Mar 20, 2024
0b32b6d
Save client status changed by value
garaimanoj Apr 2, 2024
2662dbc
Get client status changed by
garaimanoj Apr 2, 2024
f115346
Add exception handler
garaimanoj Apr 5, 2024
9db6837
Add test cases for controller
garaimanoj Apr 5, 2024
6773edd
Check isPresent before accessing optional value
garaimanoj Apr 5, 2024
8befcb9
Add licence
garaimanoj Apr 5, 2024
e430264
Add column status_changed_by to client_details
garaimanoj Apr 5, 2024
51ab5d8
Add last_used property to clients (#675)
darcato Apr 10, 2024
71391d1
Make client suspension details available to client owner
garaimanoj Apr 10, 2024
e1344d2
Merge branch 'develop' into issue-705-iam-admins-should-be-able-to-su…
garaimanoj Apr 11, 2024
f219185
Resolve FlywayException by renaming
garaimanoj Apr 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
Expand Down Expand Up @@ -140,6 +141,13 @@ public RegisteredClientDTO updateClient(@PathVariable String clientId,
return managementService.updateClient(clientId, client);
}

@PatchMapping("/{clientId}/status")
enricovianello marked this conversation as resolved.
Show resolved Hide resolved
@PreAuthorize("#iam.hasScope('iam:admin.write') or #iam.hasDashboardRole('ROLE_ADMIN')")
public void updateClientStatus(@PathVariable String clientId,
@RequestBody boolean status) {
managementService.updateClientStatus(clientId, status);
}

@PostMapping("/{clientId}/secret")
@ResponseStatus(CREATED)
@PreAuthorize("#iam.hasScope('iam:admin.write') or #iam.hasDashboardRole('ROLE_ADMIN')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ RegisteredClientDTO updateClient(@NotBlank String clientId,

void deleteClientByClientId(@NotBlank String clientId);

void updateClientStatus(String clientId, boolean status);

ListResponseDTO<ScimUser> getClientOwners(@NotBlank String clientId, @NotNull Pageable pageable);

void assignClientOwner(@NotBlank String clientId, @IamAccountId String accountId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public RegisteredClientDTO saveNewClient(RegisteredClientDTO client) throws Pars
ClientDetailsEntity entity = converter.entityFromClientManagementRequest(client);
entity.setDynamicallyRegistered(false);
entity.setCreatedAt(Date.from(clock.instant()));
entity.setActive(true);

defaultsService.setupClientDefaults(entity);
entity = clientService.saveNewClient(entity);
Expand All @@ -133,6 +134,15 @@ public void deleteClientByClientId(String clientId) {
eventPublisher.publishEvent(new ClientRemovedEvent(this, client));
}

@Override
public void updateClientStatus(String clientId, boolean status) {

ClientDetailsEntity client = clientService.findClientByClientId(clientId)
.orElseThrow(ClientSuppliers.clientNotFound(clientId));
client = clientService.updateClientStatus(client, status);
eventPublisher.publishEvent(new ClientUpdatedEvent(this, client));
}

@Validated(OnClientUpdate.class)
@Override
public RegisteredClientDTO updateClient(String clientId, RegisteredClientDTO client)
Expand All @@ -148,6 +158,7 @@ public RegisteredClientDTO updateClient(String clientId, RegisteredClientDTO cli
newClient.setClientId(oldClient.getClientId());
newClient.setAuthorities(oldClient.getAuthorities());
newClient.setDynamicallyRegistered(oldClient.isDynamicallyRegistered());
newClient.setActive(oldClient.isActive());

if (NONE.equals(newClient.getTokenEndpointAuthMethod())) {
newClient.setClientSecret(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ public RegisteredClientDTO registerClient(RegisteredClientDTO request,
ClientDetailsEntity client = converter.entityFromRegistrationRequest(request);
defaultsService.setupClientDefaults(client);
client.setDynamicallyRegistered(true);
client.setActive(true);

checkAllowedGrantTypes(request, authentication);
cleanupRequestedScopes(client, authentication);
Expand Down Expand Up @@ -410,6 +411,7 @@ public RegisteredClientDTO updateClient(String clientId, RegisteredClientDTO req
newClient.setAuthorities(oldClient.getAuthorities());
newClient.setCreatedAt(oldClient.getCreatedAt());
newClient.setReuseRefreshToken(oldClient.isReuseRefreshToken());
newClient.setActive(oldClient.isActive());

ClientDetailsEntity savedClient = clientService.updateClient(newClient);

Expand Down
Loading
Loading