feat(access-keys): 支持自定义密钥并统一编辑与生成交互 - #611
Conversation
Codex Review SummaryThis 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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: QUIET Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthrough本次变更支持自定义访问密钥,并新增前缀元数据和统一掩码。创建与更新操作加入幂等处理、管理员密钥冲突校验和恢复流程。数据库新增两项迁移,并增强 SQLite 迁移回滚处理。前端新增密钥输入、强度提示和替换确认流程,同时移除独立的密钥轮换界面。 Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to Custom access-key updates and migrations are substantially covered, but SQLite upgrades may reuse deleted access-key IDs and the recovery interface may show conflicting states. These issues should be resolved or explicitly accepted before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
🟡 Other comments (1)
web/src/features/access-keys/AccessKeyDrawer.vue-617-621 (1)
617-621: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win进入密钥对账时应清除
failed标志。
retryable-precondition的outcome.kind为failed,因此第 594 行已把failed置为true。新分支随后设置editReconciliation并把mutationState置为reconciling。结果AccessKeyOperationFeedback同时收到failed=true与accessKeys.customKey.editKeyReconciling,界面同时显示“保存失败”和“对账中”两种矛盾状态。
reconcileEdit的同类分支没有这个组合:它先把failed置为false,再设置对账状态。请在此处对齐该语义。🐛 建议的修正
const operation: PendingAccessKeyEditOperation = { base: currentBase, patch: updateBody, ...(updateBody.key ? { idempotencyKey: activeOperationID } : {}), state: outcome.kind === 'failed' ? 'reconciling' : outcome.kind, } + failed.value = false editReconciliation.value = operation editOperationRetained.value = true emit('update:editOperation', operation)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: QUIET
Plan: Advanced
Run ID: cbbd7833-6caa-4b96-ae07-0006c9a86cf7
📒 Files selected for processing (55)
internal/control/access_key_collection.gointernal/control/access_key_collection_query_test.gointernal/control/access_key_custom_test.gointernal/control/access_key_edit_credential_test.gointernal/control/access_key_idempotency.gointernal/control/access_key_mask_test.gointernal/control/access_key_rotation.gointernal/control/access_key_update_idempotency.gointernal/control/access_keys.gointernal/control/access_keys_phase1_test.gointernal/control/bootstrap.gointernal/control/health.gointernal/control/home.gointernal/control/idempotency_digest.gointernal/control/idempotency_operation.gointernal/control/operation_recovery.gointernal/control/server.gointernal/platform/errors/errors.gointernal/platform/i18n/locales/en-US.gointernal/platform/i18n/locales/ja-JP.gointernal/platform/i18n/locales/zh-CN.gointernal/state/loader/loader.gointernal/state/snapshot.gointernal/storage/access_key_prefix_migration_test.gointernal/storage/custom_access_key_migration_test.gointernal/storage/database_integration_test.gointernal/storage/db_test.gointernal/storage/migration.gointernal/storage/migration_sqlite.gointernal/storage/migration_sqlite_test.gointernal/storage/migration_test.gointernal/storage/migrations/0007_access_key_lifecycle_test.gointernal/storage/migrations/0011_custom_access_keys.gointernal/storage/migrations/0012_access_key_mask_prefix.gointernal/storage/models/access_key.goweb/src/api/control/types.tsweb/src/app/mutation-outcome.tsweb/src/app/resources/access-keys.tsweb/src/app/resources/invalidation.tsweb/src/components/ui/AppConfirmDialog.vueweb/src/components/ui/AppDialog.vueweb/src/components/ui/AppTextInput.vueweb/src/features/access-keys/AccessKeyCredentialField.vueweb/src/features/access-keys/AccessKeyDrawer.vueweb/src/features/access-keys/AccessKeyFormFields.vueweb/src/features/access-keys/AccessKeyRotateDialog.vueweb/src/features/access-keys/AccessKeysView.vueweb/src/features/access-keys/access-key-create-operation.tsweb/src/features/access-keys/access-key-edit-operation.tsweb/src/features/access-keys/access-key-patch.tsweb/src/features/access-keys/access-key-rotate-operation.tsweb/src/features/access-keys/access-key-strength.tsweb/src/i18n/locales/en-US/access-keys.tsweb/src/i18n/locales/ja-JP/access-keys.tsweb/src/i18n/locales/zh-CN/access-keys.ts
💤 Files with no reviewable changes (4)
- web/src/api/control/types.ts
- web/src/app/resources/invalidation.ts
- web/src/features/access-keys/AccessKeyRotateDialog.vue
- web/src/features/access-keys/access-key-rotate-operation.ts
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e9cfef8c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
关联 Issue / Related Issue
无。
变更内容 / Change Content
访问密钥支持自定义值,新增和编辑共用输入框,末尾连接骰子图标按钮,悬停提示「随机生成」。新增留空由系统生成,编辑留空保持原值;随机生成使用安全随机数,只填入草稿,保存成功后才生效。界面移除独立轮换按钮和弹窗。弱密钥显示三档强度估算,允许确认后保存;编辑更换密钥时,将旧密钥失效和弱密钥警告合并为一次确认。
包含新密钥的编辑请求将密钥与其他配置在同一事务中保存,保留原 ID、权限、额度和已用金额,并通过现有幂等操作与快照恢复机制确保重试不会覆盖后来的修改。
PUT /api/access-keys/:id在key非空时要求Idempotency-Key;省略或传入空字符串保持原密钥。现有轮换 API 保留。后端仅校验可用字符、256 字符上限、唯一性和管理员密钥冲突,不设置强度门槛;凭据加密保存,幂等摘要使用 HMAC 指纹。掩码按长度分档:超过 16 位显示实际前 6 位及末 4 位,9–16 位仅显示末 4 位,8 位及以下完全隐藏。默认生成密钥保持原有的
sk-gl-****abcd格式。新增
0011_custom_access_keys放宽尾号字符约束,0012_access_key_mask_prefix保存脱敏前缀,使元数据读取无需解密。SQLite 重建表在迁移专用连接和写事务中执行,提交前校验外键并恢复连接设置,保留已有密钥、额度规则、用量检查点、索引和编号序列。验证:最终
make check通过;覆盖编辑空值保留、弱密钥保存、额度保留、原子回滚、相同掩码下的幂等区分、旧操作重试及提交后的快照恢复。迁移合同已使用 SQLite、真实 MySQL 8.0 和 PostgreSQL 16 验证新库、已有库、重复执行和中断恢复。按仓库规则未运行前端测试或本地 race 测试。自查清单 / Checklist
make check,或在说明中写明无法运行的原因和未验证范围。 / I ranmake check, or documented why it could not run and what remains unverified.本次未修改公开文档或发布说明。