Skip to content

feat: add realm trust anchor management - #3260

Merged
tada5hi merged 5 commits into
masterfrom
feat/key-store-trust-anchors
Jul 15, 2026
Merged

tada5hi merged 5 commits into
masterfrom
feat/key-store-trust-anchors

Conversation

@tada5hi

@tada5hi tada5hi commented Jul 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add realm-scoped trusted CA storage, validation, permissions, repository, service, and HTTP controllers
  • expose typed client APIs and Trusted CAs management inside the key-management UI
  • add MySQL and PostgreSQL schema support plus service, controller, and validation coverage
  • document the separation between signing keys and trust anchors

Dependency

This builds on the certificate-key support merged in #3257.

Validation

  • focused trust-anchor tests: 19 passed
  • server and client typechecks passed
  • server, client, client-web-kit, and i18n builds/tests passed
  • root lint passed
  • MySQL and PostgreSQL migration run, constraint inspection, revert, and re-run passed
  • full server run: 1657 tests passed; one unrelated shared-SQLite permission suite had four parallel-run failures and passed 9/9 in isolation

Summary by CodeRabbit

  • New Features
    • Added Trusted CAs management for each realm.
    • Users can create, view, edit, enable or disable, and delete trusted CA certificates.
    • Added certificate validation, duplicate-name prevention, permission controls, search, and pagination.
    • Added API support for listing and managing trusted CAs.
  • Documentation
    • Updated architecture documentation to describe Trusted CAs and their rollout stage.
  • Tests
    • Added coverage for permissions, certificate validation, realm scoping, CRUD operations, and duplicate handling.

Copilot AI review requested due to automatic review settings July 15, 2026 08:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added realm-scoped Trusted CA storage with TypeORM persistence, permission-aware CRUD services, HTTP and client APIs, validation, localized management pages, database migrations, and unit/controller tests.

Changes

Trust Anchor functionality

Layer / File(s) Summary
Trust Anchor contracts and APIs
packages/core-kit/..., packages/core-http-kit/..., apps/server-core/src/core/entities/...
Adds the TrustAnchor model, validation rules, entity mapping, service/repository contracts, and typed client CRUD API.
Persistence and domain service
apps/server-core/src/adapters/database/..., apps/server-core/src/app/modules/database/..., apps/server-core/src/core/entities/trust-anchor/...
Creates the realm-bound auth_trust_anchors table, repository adapter, permission-aware CRUD service, and HTTP controller wiring.
Management UI and localization
packages/client-web-kit/..., apps/client-web/pages/keys/..., packages/i18n/...
Adds Trust Anchor collection, form, detail, add, navigation, toast handling, and localized labels.
Service and controller validation
apps/server-core/test/unit/...
Tests permissions, realm scoping, CA certificate validation, uniqueness, updates, deletion, and nested HTTP routes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: copilot

Sequence Diagram(s)

sequenceDiagram
  participant Administrator
  participant KeysUI
  participant TrustAnchorAPI
  participant TrustAnchorController
  participant TrustAnchorService
  participant TrustAnchorRepository
  Administrator->>KeysUI: Open Trusted CAs
  KeysUI->>TrustAnchorAPI: List or submit Trust Anchor
  TrustAnchorAPI->>TrustAnchorController: HTTP CRUD request
  TrustAnchorController->>TrustAnchorService: Build actor context and invoke operation
  TrustAnchorService->>TrustAnchorRepository: Validate realm, certificate, permissions, and uniqueness
  TrustAnchorRepository-->>TrustAnchorService: Persisted Trust Anchor
  TrustAnchorService-->>TrustAnchorController: Trust Anchor response
  TrustAnchorController-->>TrustAnchorAPI: Entity response
  TrustAnchorAPI-->>KeysUI: Render updated state
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding realm-scoped trust anchor management.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/key-store-trust-anchors

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

authup

npm i https://pkg.pr.new/authup@3260

@authup/client-web

npm i https://pkg.pr.new/@authup/client-web@3260

@authup/server-core

npm i https://pkg.pr.new/@authup/server-core@3260

@authup/access

npm i https://pkg.pr.new/@authup/access@3260

@authup/client-web-kit

npm i https://pkg.pr.new/@authup/client-web-kit@3260

@authup/client-web-kit-theme

npm i https://pkg.pr.new/@authup/client-web-kit-theme@3260

@authup/client-web-nuxt

npm i https://pkg.pr.new/@authup/client-web-nuxt@3260

@authup/client-web-theme

npm i https://pkg.pr.new/@authup/client-web-theme@3260

@authup/core-http-kit

npm i https://pkg.pr.new/@authup/core-http-kit@3260

@authup/core-kit

npm i https://pkg.pr.new/@authup/core-kit@3260

@authup/core-realtime-kit

npm i https://pkg.pr.new/@authup/core-realtime-kit@3260

@authup/errors

npm i https://pkg.pr.new/@authup/errors@3260

@authup/i18n

npm i https://pkg.pr.new/@authup/i18n@3260

@authup/kit

npm i https://pkg.pr.new/@authup/kit@3260

@authup/server-adapter-kit

npm i https://pkg.pr.new/@authup/server-adapter-kit@3260

@authup/server-adapter-node

npm i https://pkg.pr.new/@authup/server-adapter-node@3260

@authup/server-adapter-socket-io

npm i https://pkg.pr.new/@authup/server-adapter-socket-io@3260

@authup/server-adapter-web

npm i https://pkg.pr.new/@authup/server-adapter-web@3260

@authup/server-kit

npm i https://pkg.pr.new/@authup/server-kit@3260

@authup/server-test-kit

npm i https://pkg.pr.new/@authup/server-test-kit@3260

@authup/specs

npm i https://pkg.pr.new/@authup/specs@3260

commit: daae320

@tada5hi

tada5hi commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai pause

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (2)
apps/server-core/test/unit/core/entities/trust-anchor/service.spec.ts (1)

46-186: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add unit tests for getOne.

The test suite thoroughly covers getMany, create, update, and delete. However, test coverage for the getOne method implemented in TrustAnchorService appears to be missing. Consider adding a describe('getOne') block to verify successful retrieval, permission evaluation, and the EntityNotFoundError when the anchor does not exist.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/server-core/test/unit/core/entities/trust-anchor/service.spec.ts` around
lines 46 - 186, Add a describe('getOne') block for TrustAnchorService covering
successful retrieval of a seeded anchor, permission evaluation for the requested
anchor, and rejection with EntityNotFoundError when the ID is absent. Reuse the
existing repository, actor factories, and trust-anchor builders, and assert the
returned entity and relevant permission behavior.
apps/client-web/pages/keys/index.vue (1)

93-106: 🎯 Functional Correctness | 🔵 Trivial

Verify locale word-order for concatenated nav labels.

${translationsDefault.add} ${keySingular.value} / ${trustAnchorSingular.value} builds "Add X" via raw string concatenation of two independently-translated fragments. This file already has a placeholder-based pattern available (ENTITY_DELETED with data: { entity, name }, lines 113-124) that composes sentences correctly per-locale; concatenation instead hardcodes English word order and can render incorrect grammar in German/French/Spanish where verb/object order differs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/client-web/pages/keys/index.vue` around lines 93 - 106, Update the
concatenated add-navigation labels in the menu definition to use the locale’s
placeholder-based translation pattern, passing the translated entity name as
interpolation data instead of joining translations manually. Apply this to both
the key and trust-anchor entries while preserving their existing icons and URLs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/client-web/pages/keys/index/trust-anchors/`[id].vue:
- Around line 2-7: Import the VCNavItems component in the trust-anchor page and
add it to the component’s local registration alongside ATrustAnchorForm. Ensure
the existing template usage of VCNavItems resolves through this explicit
registration.

In `@apps/client-web/pages/keys/index/trust-anchors/index.vue`:
- Line 44: Make the trust-anchor query in the setup logic reactive by wrapping
the filter object containing realmManagementId.value in computed(...), then pass
the computed query to ATrustAnchors so it updates when the management realm
changes.

In `@apps/server-core/src/core/entities/trust-anchor/service.ts`:
- Around line 154-156: Update the update method after validator.run and before
permission evaluation to mirror create’s CA certificate validation: when
validated.certificate is present, parse it and verify it is a valid CA
certificate using the existing certificate-validation logic and error behavior.

In
`@packages/client-web-kit/src/components/entities/trust-anchor/ATrustAnchorForm.vue`:
- Line 66: Update the submit function to return immediately when busy is already
true, set busy to true before calling createOrUpdate, and reset it in a finally
block so the loading state and re-entrancy guard cover both success and failure.
Preserve the existing submit behavior and ensure the returned busy binding
reflects the request lifecycle.

---

Nitpick comments:
In `@apps/client-web/pages/keys/index.vue`:
- Around line 93-106: Update the concatenated add-navigation labels in the menu
definition to use the locale’s placeholder-based translation pattern, passing
the translated entity name as interpolation data instead of joining translations
manually. Apply this to both the key and trust-anchor entries while preserving
their existing icons and URLs.

In `@apps/server-core/test/unit/core/entities/trust-anchor/service.spec.ts`:
- Around line 46-186: Add a describe('getOne') block for TrustAnchorService
covering successful retrieval of a seeded anchor, permission evaluation for the
requested anchor, and rejection with EntityNotFoundError when the ID is absent.
Reuse the existing repository, actor factories, and trust-anchor builders, and
assert the returned entity and relevant permission behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f62a34d7-70b5-4f6b-a818-bea4c713c975

📥 Commits

Reviewing files that changed from the base of the PR and between e59a075 and 4c77307.

⛔ Files ignored due to path filters (1)
  • apps/server-core/test/data/certificates/non-ca-certificate.pem is excluded by !**/*.pem
📒 Files selected for processing (49)
  • .agents/architecture.md
  • apps/client-web/pages/keys/index.vue
  • apps/client-web/pages/keys/index/trust-anchors.vue
  • apps/client-web/pages/keys/index/trust-anchors/[id].vue
  • apps/client-web/pages/keys/index/trust-anchors/add.vue
  • apps/client-web/pages/keys/index/trust-anchors/index.vue
  • apps/server-core/src/adapters/database/data-source/options/module.ts
  • apps/server-core/src/adapters/database/domains/index.ts
  • apps/server-core/src/adapters/database/domains/trust-anchor/entity.ts
  • apps/server-core/src/adapters/database/domains/trust-anchor/index.ts
  • apps/server-core/src/adapters/database/migrations/mysql/1783856507391-Default.ts
  • apps/server-core/src/adapters/database/migrations/postgres/1783856507391-Default.ts
  • apps/server-core/src/adapters/http/controllers/entities/index.ts
  • apps/server-core/src/adapters/http/controllers/entities/trust-anchor/index.ts
  • apps/server-core/src/adapters/http/controllers/entities/trust-anchor/module.ts
  • apps/server-core/src/app/modules/database/repositories/index.ts
  • apps/server-core/src/app/modules/database/repositories/trust-anchor/index.ts
  • apps/server-core/src/app/modules/database/repositories/trust-anchor/repository.ts
  • apps/server-core/src/app/modules/http/modules/controller.ts
  • apps/server-core/src/core/entities/index.ts
  • apps/server-core/src/core/entities/trust-anchor/index.ts
  • apps/server-core/src/core/entities/trust-anchor/service.ts
  • apps/server-core/src/core/entities/trust-anchor/types.ts
  • apps/server-core/test/unit/core/entities/trust-anchor/fake-repository.ts
  • apps/server-core/test/unit/core/entities/trust-anchor/service.spec.ts
  • apps/server-core/test/unit/http/controllers/entities/trust-anchor.spec.ts
  • packages/client-web-kit/src/components/entities/index.ts
  • packages/client-web-kit/src/components/entities/trust-anchor/ATrustAnchor.ts
  • packages/client-web-kit/src/components/entities/trust-anchor/ATrustAnchorForm.vue
  • packages/client-web-kit/src/components/entities/trust-anchor/ATrustAnchors.ts
  • packages/client-web-kit/src/components/entities/trust-anchor/index.ts
  • packages/core-http-kit/src/client/module.ts
  • packages/core-http-kit/src/client/type.ts
  • packages/core-http-kit/src/domains/entities/index.ts
  • packages/core-http-kit/src/domains/entities/trust-anchor/index.ts
  • packages/core-http-kit/src/domains/entities/trust-anchor/module.ts
  • packages/core-http-kit/src/domains/entities/trust-anchor/types.ts
  • packages/core-kit/src/domains/contstants.ts
  • packages/core-kit/src/domains/index.ts
  • packages/core-kit/src/domains/trust-anchor/index.ts
  • packages/core-kit/src/domains/trust-anchor/types.ts
  • packages/core-kit/src/domains/trust-anchor/utils.ts
  • packages/core-kit/src/domains/trust-anchor/validator.ts
  • packages/core-kit/src/domains/types.ts
  • packages/i18n/src/catalogs/de/entity.ts
  • packages/i18n/src/catalogs/en/entity.ts
  • packages/i18n/src/catalogs/es/entity.ts
  • packages/i18n/src/catalogs/fr/entity.ts
  • packages/i18n/src/constants.ts

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews paused.

tada5hi added 4 commits July 15, 2026 10:21
…ble submission

The busy ref on AKeyForm and ATrustAnchorForm was passed to AFormSubmit
(:is-busy) but never set, so the submit button showed no in-flight state
and an in-flight submit was not blocked. Set busy around the createOrUpdate
call and short-circuit submit while busy.
buildCertificateJwkFields was duplicated verbatim in the JwkController and
the realm jwks handlers. Hoist it into core/key/certificate.ts alongside
buildX5c/buildX5tS256 so the fail-open x5c/x5t#S256 derivation has a single
source of truth.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants