Repository navigation
fix(api): persist permission-only API keys without roles - #2152
Eli Bosley (elibosley) wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
ChangesAPI key creation
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2152 +/- ##
==========================================
+ Coverage 54.28% 54.31% +0.02%
==========================================
Files 1046 1046
Lines 73608 73608
Branches 8845 8861 +16
==========================================
+ Hits 39956 39978 +22
+ Misses 33526 33504 -22
Partials 126 126 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This plugin has been deployed to Cloudflare R2 and is available for testing. |
Creating a permission-only API key from the CLI fails when
--rolesis omitted. Default omitted roles to an empty array inApiKeyService.create, so the key passes the existing model validation and retains only its requested permissions.The service owns this normalization for every creation caller, including permission-only overwrites. Explicit roles and rejection of empty grants remain covered. The model and authorization rules remain unchanged.
Added seven regression cases that use the real service, model validation, JSON persistence, and disk loading in a temporary directory. CLI cases exercise permission parsing and confirm that creation does not prompt or exit.
Validation: 93 tests passed across the API key service, both existing CLI suites, the new persistence suite, and GraphQL mutations. API type checking and lint passed. Before the fix, the new suite failed on omitted-role creation and permission-only overwrite.
QA: Use the PR plugin build on a test Unraid host. Run
unraid-api apikey --create --name "Array Read Test" --permissions "ARRAY:READ_ANY". Expect a key without a prompt or validation error. Inspect its key JSON privately:rolesmust be[], and permissions must contain only ARRAY with READ_ANY. Confirm that the key can read array data and cannot perform an ungranted operation. Repeat role-only and interactive permission-only creation, then remove the test keys. Do not attach key values to the ticket.Work intent: permission-only CLI creation and persistence, approved by the maintainer's implementation request. Low risk: one normalization change at the existing service boundary. Live Unraid validation remains for QA.
Fixes #2151
Related to CLD-1451
Release note: Fixed permission-only API key creation from the CLI when
--rolesis omitted.Summary by CodeRabbit