Repository navigation
feat(sse): manage KMS key lifecycle from the key list - #328
Merged
Merged
Conversation
The Console could create, inspect and delete KMS keys but offered no way to enable, disable or rotate one, even though the server exposes all three endpoints (rustfs#320, Part B1). Key rows now offer them next to the existing deletion flow, on both the mobile cards and the desktop menu. Each action rechecks its own IAM action when confirmed (kms:EnableKey, kms:DisableKey, kms:RotateKey) through the confirmation dialog deletion already used, so a stale list cannot mutate a key the caller may not touch. The recheck also keeps the default-SSE-key guard where it belongs: enable, disable and rotate are safe for the default key, so only deletion compares against it. Visibility follows the server's capability matrix instead of assuming every backend can do everything: Enable and Disable are offered when `enable_disable` is not false and Rotate when `rotate` is not false, while an absent matrix leaves them available because absence means the server did not say, not that the backend refuses. Enable appears for a key the server reports as Disabled, Disable for a usable key — the listing calls that "Active" while lifecycle responses call it "Enabled", so both count — and Rotate is hidden for keys pending deletion. Wire contract: POST /kms/keys/{enable,disable,rotate} with `{ key_id }`, per rustfs/rustfs `rustfs/src/admin/handlers/kms_key_lifecycle.rs`.
Contributor
Author
overtrue
approved these changes
Nov 30, 2026
overtrue
left a comment
Collaborator
There was a problem hiding this comment.
LGTM on the KMS key lifecycle management changes.
Summary of Review
- Types & API Client (
types/kms.ts,hooks/use-sse.ts):KmsKeyLifecycleRequest,KmsKeyLifecycleResponse, androtateKey/enableKey/disableKeyfollow the existing mutation patterns and endpoint conventions (/kms/keys/rotate,/kms/keys/enable,/kms/keys/disable).
- SSE Page Lifecycle Controls & Permissions (
app/(dashboard)/sse/page.tsx):KEY_ACTION_PERMISSIONSmaps each confirmed action to its exact IAM permission (kms:EnableKey,kms:DisableKey,kms:RotateKey), andhandleConfirmKeyActionrechecks the matching permission before calling the API.- Default-key deletion protection is properly scoped to
scheduleDeleteandforceDelete, leavingenable,disable, androtateavailable for the default key. getKeyLifecycleActionsgates visibility oncapabilities?.enable_disable !== falseandcapabilities?.rotate !== false(keeping omitted capability flags available) and handles both"Enabled"/"Active"and"Disabled"/"PendingDeletion"states.- Error paths (
response.success === falseand thrown errors) close the confirmation dialog and reconcile state without leaving stale locks. - Minor non-blocking note:
rotatevisibility checks!isKeyPendingDeletion(key.status) && !isKeyDisabled(key.status), which would also renderRotatefor states such as"PendingImport"or"Unavailable"if a backend ever emits them, thoughhandleConfirmKeyActionstill surfaces backend rejections cleanly.
- i18n & Tests (
i18n/locales/*.json,tests/hooks/use-sse.test.ts,tests/lib/management-permission-controls.test.ts):- All 14 locale files include consistent translations for the new UI strings.
- Unit and permission-control tests directly cover endpoint payloads, permission rechecks, capability gating,
"Active"status normalization, and hidingRotateonPendingDeletion. All 10 CI checks are green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Part B1 of #320. The Console could create, inspect and delete KMS keys, but offered no way to enable, disable or rotate one, even though the server exposes all three endpoints. Key rows now offer them next to the existing deletion flow — as buttons on the mobile cards and as menu items in the desktop table.
Behaviour:
rustfs/rustfs,rustfs/src/admin/handlers/kms_key_lifecycle.rs):POST /kms/keys/{enable,disable,rotate}with{ key_id }, returning{ success, message, key_id, key_metadata }.hooks/use-sse.tsgainsenableKey,disableKey,rotateKey;types/kms.tsgains the request/response types.kms:EnableKey,kms:DisableKey,kms:RotateKey— through the same confirmation dialog deletion already used, so a stale key list cannot mutate a key the caller may no longer be allowed to touch. The dialog's action and permission now come from oneKEY_ACTION_PERMISSIONSmap instead of hardcodingkms:DeleteKey.config_summary.default_key_id— previously any non-cancel action did.capabilities.enable_disableis notfalse, Rotate whencapabilities.rotateis notfalse. An absent capability matrix leaves all three available, because absence means "the server did not say", not "the backend refuses" — the same rule the page already follows for the rekey card.Disabled, Disable for a usable key, and Rotate is hidden for keys pending deletion. Note the server's naming: the key listing calls a usable keyActive, while lifecycle responses call the same stateEnabled, so both are treated as enabled (rustfs/rustfskms_key_lifecycle.rsreturnskey_state: "Enabled",GET /kms/keysreturnsstatus: "Active").Enable/Disablereuse the existing translations.Type of Change
Testing
Unit tests:
tests/hooks/use-sse.test.tsmounts the realuseSSEhook with a stubbed API client and pins the exact endpoint and body of all three calls.tests/lib/management-permission-controls.test.tsmounts the page and asserts: confirming Disable recheckskms:DisableKeyand calls the hook; confirming Enable recheckskms:EnableKeyand neverkms:DeleteKey; capabilities{enable_disable: false, rotate: false}hide both actions; an absent matrix keeps them available; a key reported asActiveoffers Disable and not Enable; a key pending deletion is not offered Rotate.Manual verification against a real server:
1.0.xrunning with Local KMS: the listing reportsActive, so Disable is offered; after disabling, the row reportsDisabledand offers Enable. Local declaresrotate: false, and Rotate is correctly absent from the menu.rotate: true): the row offers View Details / Disable / Rotate. Confirming Rotate through the dialog rotated the key on the server — its version went from 1 to 2.Checklist
Related Issues
Part of #320 (Part B, item 1 — key lifecycle). Backup/restore, key metadata and the remaining parity endpoints are still open.
Screenshots (if applicable)
Key list actions, 420 px mobile layout (the desktop table carries the same items in its Actions menu):
rotate: false.Screenshots attached below.
Additional Notes
rotate: true.501when a capability was reported optimistically) surfaces the server's own message through the existing error path, and the dialog closes with the key list reloaded.