Commit Graph
2272 Commits
Author SHA1 Message Date
Vickey 2f646bf3ea docs(gateway): add openapi operations and javadoc to mcp gateway
Add @Operation to the MCP gateway endpoints (protected-resource metadata, JSON-RPC handler) and behavior-accurate method JavaDoc. Docs only, no logic changes.
2026-06-18 20:14:16 +08:00
pnoker f217460c32 docs(agentic): normalize controller javadoc
Add behavior-accurate method JavaDoc (@param/@return) across agentic controllers. Comment docs only, no logic changes.
2026-06-18 20:14:16 +08:00
pnoker bbd054d0c4 docs(data): normalize controller javadoc and openapi parameters
Add behavior-accurate method JavaDoc (@param/@return) across data controllers and normalize @Parameter descriptions with examples. Correct two @Operation descriptions that wrongly claimed to return new ids. Docs only, no logic changes.
2026-06-18 20:14:16 +08:00
pnoker cc925a8f3b docs(auth): normalize controller javadoc and add oauth openapi operations
Add behavior-accurate method JavaDoc (@param/@return) across auth controllers and normalize @Parameter descriptions. Add @Operation to the six OAuth 2.1 endpoints (discovery, jwks, register, authorize, token, revoke) that previously had none. Docs only, no logic changes.
2026-06-18 20:14:16 +08:00
pnoker cc7ec6bb63 docs(manager): normalize controller javadoc and openapi parameters
Replace stub method JavaDoc (bare ID/Device placeholders) with behavior-accurate descriptions, @param and @return across manager controllers; normalize @Parameter descriptions with examples. Comment and annotation docs only, no logic changes.
2026-06-18 20:14:16 +08:00
pnoker 8995dd5ab8 docs(dc3-common): normalize @Schema/@Parameter across API layer
Standardize description wording, add scalar-field examples, mark required
fields via requiredMode, and drop examples from object/collection fields.
Spans VO/Query/ext/controller plus related BO/DTO/response types.
2026-06-18 19:53:27 +08:00
pnoker cba2d54780 docs: align Make command references with new compose shortcuts
Update READMEs, guides, USAGE and the stack-test skill to use the
up-<stack>[-<registry>] targets in place of the removed dev-* commands.
2026-06-18 18:42:28 +08:00
pnoker 35d985e2f3 build: add compose shortcut targets and drop commit-msg lint hook
Generate <op>-<stack>[-<registry>] compose shortcuts and test/coverage
targets in the Makefile, remove the install-hooks target and the
.githooks commit-msg linter, and document the design.
2026-06-18 18:42:20 +08:00
pnoker a230ffd9fe refactor(auth): bind OAuth runtime settings via @ConfigurationProperties
Replace the scattered @Value injections in OAuthMcpRuntimeServiceImpl
with a typed OAuthProperties bean covering issuer, audience, TTLs and
JWT key material.
2026-06-18 18:35:05 +08:00
pnoker d6171c9d04 refactor(data): rename AlertBulkConfirmRequest to AlertBulkConfirmVO
Move the bulk-confirm payload to the VO naming used by the dashboard
endpoints and update the service and controller references.
2026-06-18 18:34:55 +08:00
pnoker bd15ff2487 refactor(agentic): replace request DTOs with VO/DTO/BO entities
Drop the entity/request package and route controller, service, builder
and runtime paths through ChatCompletionVO, ModelConfigVO/ModelProviderVO,
the relocated dto/ChatMessageDTO and the renamed AgenticPreparedChatBO.
2026-06-18 18:34:16 +08:00
pnoker 582f103d42 docs(agents): document the read-only projection VO exception
Record that read-only projection/aggregation responses (dashboard stats, health
snapshots, topic/model-option listings, history queries) may be returned directly
as VO without a parallel BO; the "services expose BO" rule applies to persistent
business entities and write-path business inputs.
2026-06-18 17:19:10 +08:00
pnoker 3ecc78e072 test: align route contract and manager metadata tests with backend behaviour
The route-naming contract treated constant-defined mappings (e.g.
McpConstant.OAUTH2_TOKEN) as empty routes because it only scanned string literals;
recognise a constant reference as a real route. The metadata listener and driver
gRPC server tests stubbed driver lookups with a hardcoded tenant 1L, but the
tenant-safe production code passes null for the system-level metadata broadcast
and the driver's own tenant for the metadata snapshot; stub the matching tenant.
2026-06-18 17:18:01 +08:00
pnoker a35f01c4c6 refactor(auth): use snake_case request params on the MCP audit endpoint
Rename the camelCase query params on the MCP audit listing (principalId, toolId,
riskLevel) to snake_case to satisfy the public HTTP route-naming contract.
2026-06-18 17:17:50 +08:00
pnoker 7a4e74b4fc refactor(manager): drop IService inheritance from TopicService
TopicService is a read-only projection over devices and points and never used any
MyBatis-Plus IService method, yet exposed the full DeviceDO persistence API on the
service boundary. Make it a plain service backed by Db.lambdaQuery, and drop the
manual deleted=0 filter (handled by @TableLogic) along with two dead commented-out
enableFlag filters.
2026-06-18 17:17:40 +08:00
pnoker 654f3173fc refactor(data): accept BO instead of VO for command and event write paths
Move the four command-submission inputs (point read/write, command call, event
report) off web VO types and onto dedicated BO types so the data service and
facade layers no longer depend on request VOs. Controllers and the gRPC servers
convert the inbound VO/request into the BO via PointCommandBuilder and the
command/event builders; PointCommandLocalFacade builds the BO directly. The
RabbitMQ EventReportDTO overload and read-only history projections are unchanged.
2026-06-18 17:17:23 +08:00
Vickey 2d7f970701 feat(common): add RequirePasswordChangeFlagEnum for local credentials
Replace the naked Byte requirePasswordChange flag on LocalCredentialBO/VO with a
domain enum (NOT_REQUIRED/REQUIRED), mirroring ConfirmFlagEnum. The DO keeps Byte
for persistence; the builder converts via getIndex()/ofIndex(), and the few
existing call sites (LocalCredentialServiceImpl, TokenServiceImpl, tests) compare
against the enum instead of magic 0/1 literals.
2026-06-18 17:16:49 +08:00
Vickey 7a694ce4bc refactor(auth): return BO/VO instead of DO from audit-log and tenant-membership services
Stop leaking persistence entities through the audit-log and tenant-membership
service boundaries. AuditLogService.list now returns IdentityAuditLogBO and the
controller maps it to the new IdentityAuditLogVO via IdentityAuditLogBuilder, so
the dc3_identity_audit_log table shape is no longer the public API response.
TenantMembershipService.add/getByTenantIdAndPrincipalId accept and return BO;
callers in UserController, ServiceAccountServiceImpl and TenantMembershipController
build BO instead of hand-populating DO.
2026-06-18 17:16:26 +08:00
Vickey 88284e4a86 chore(build): trim Makefile targets and phony list
Remove the test/coverage, app/dev, and compose-* alias targets along
with their check-* guards, and drop the matching .PHONY and MVN_SUB
entries. Reorder deploy and install-hooks under the trimmed target set.
2026-06-18 15:45:56 +08:00
Vickey c6768b5fa1 docs(openapi): enrich operation and schema docs for MCP tool exposure
Rewrite @Operation summary/description across all center controllers
(manager, auth, data, agentic) from mechanical restatements into
MCP-tool-grade prose: what the endpoint does, when to call it, the
return shape, tenant scope and side effects. Disambiguate sibling
endpoints so an LLM can select the right tool.

Fix the shared @Parameter id description that read "entity to delete"
on non-delete endpoints (getById/enable/disable) — keep it for delete,
use a neutral wording elsewhere. Enrich VO @Schema descriptions with
examples and required-mode hints. These feed the MCP tool catalog
(description via runtime scan, input schema via the OpenAPI snapshot).
2026-06-18 15:45:38 +08:00
Vickey a94b2464a4 feat(mcp): authorize high-risk tool calls and harden auth lifecycle
Tool authorization (HIGH-risk confirmation):
- add AuthorizeToolCall RPC; the gateway calls it before tool execution
- sign/consume confirmation tickets with idempotency-key dedup
- propagate x-dc3-ai metadata (riskLevel/destructive/openWorld/idempotent) from the scan through the registry to the tool catalog

OAuth hardening:
- rotate refresh tokens and revoke the authorization on replay via previous_refresh_token_hash

Password lifecycle:
- require password change on login when flagged or expired (R20303/R20304)
- expose a public POST /token/change_password endpoint

OpenAPI aggregation:
- switch McpOpenApiAggregator to classpath static snapshots, dropping the runtime fetch and McpAggregatorProperties
2026-06-18 14:08:05 +08:00
Vickey cc29d53904 docs: mark identity and mcp design proposals as landed
- update identity-principal-service-account design to reflect implemented behavior
- align mcp-server design with authoritative implementation details
2026-06-18 14:06:12 +08:00
Vickey c084fa4bd0 feat(common): add thread-bound TenantContextHolder for tenant-line integration
- introduce TenantContextHolder holding tenantId with a runIgnore closure
- bind/clear the holder in BaseController.async from the reactive security context
- add unit tests for set/get and runIgnore semantics
2026-06-18 14:05:41 +08:00
Vickey 123a5a5bb5 refactor(auth): remove unused RequirePermission annotation and tidy up
- delete the RequirePermission annotation (no references in repo)
- drop unused imports in AuditLogController and PrincipalController
- return empty list instead of null in RoleResourceBindServiceImpl
- reformat McpAuditCommand/McpToolRecord javadoc and IdentityAuditLogMapper.xml
2026-06-18 14:04:30 +08:00
Vickey 398faca2e9 fix(gateway): default MCP WebClient builder and route all auth paths via wildcard
Default-initialize the MCP introspect WebClient.Builder so the gateway
starts when no WebClient.Builder bean is present.

Replace the explicit auth-route path list with /api/v3/auth/** (the public
/token path stays carved out purely by route ordering). This is required so
new auth endpoints route correctly — the old list omitted /principal,
/tenant_membership, /identity_audit and /mcp management.
2026-06-15 09:11:46 +08:00
pnoker fe48fd3ffa fix(driver): migrate point value publish confirm to ConfirmCallback
Spring AMQP removed CorrelationData.getFuture(); move point-value
publish-confirmation logging onto RabbitTemplate.setConfirmCallback and
carry device/point context through a PointValueCorrelation subclass.
2026-06-15 09:11:46 +08:00
pnoker 195f9540bc feat(auth): add identity/authorization change audit log
New dc3_identity_audit_log table + IdentityAuditLogDO/Manager/Mapper +
AuditLogService.log() write entry point (never throws — audit must not
break the audited operation) and a tenant-scoped, filtered read API
(POST /identity_audit/list, admin RBAC).

Wire recording into the identity controllers: service account and
principal enable/disable, and tenant membership add/remove.
2026-06-14 07:59:05 +08:00
pnoker dbf53b022c feat(mcp): add read API for the tool call audit log
dc3_mcp_audit_log is already written on every tools/call; expose a
tenant-scoped, filtered listAudit read path (mapper SELECT + service +
GET /mcp/audit/list) so the audit can be queried, not only recorded.
McpAuditCommand gains a createTime field populated on read-back.
2026-06-13 23:10:46 +08:00
pnoker 0f242a0535 feat(mcp): derive tool schemas from openapi and harden client registration
Add McpOpenApiAggregator (config-gated, off by default) that fetches each
service's /v3/api-docs and stores the JSON request schema per tool in
tool_ext; McpToolRecord gains a toolExt field, the mapper persists it, and
tools/list surfaces the real schema instead of the static default. Zero
regression when the aggregator is disabled.

registerClient now pins the client to the authenticated caller's tenant
(ignoring the body tenant id) and requires an authenticated principal,
closing a cross-tenant client-registration hole; add boundary tests.

Gate OAuth dynamic client registration (/oauth2/register): open in
dev/test, closed in pre/pro unless dc3.oauth.dcr.enabled=true.

ServiceAccount: add /enable and /disable endpoints reusing the full
update path so the linked principal stays in sync.
2026-06-13 22:56:41 +08:00
pnoker ff8d86bd53 feat(auth): add principal and tenant membership management APIs
Principal: list/get-by-id/enable/disable service + controller (admin RBAC,
the principal roster is a platform identity view scoped by permission).

TenantMembership: add BO/VO/Query/Builder, paged list + get-by-id on the
service, and a tenant-scoped controller (list/add pinned to the caller's
tenant; delete verifies ownership before removing).

AuthConstant: add PRINCIPAL_URL_PREFIX and TENANT_MEMBERSHIP_URL_PREFIX.
2026-06-13 22:56:18 +08:00
pnoker 0feba780ee feat: update pom version 2026-06-13 11:15:32 +08:00
pnoker 650c192ea0 refactor(mcp): centralize gateway backend properties v2026.6.12 2026-06-12 23:01:49 +08:00
pnoker 8ea0c0faf3 refactor(mcp): route runtime calls through facade 2026-06-12 22:38:30 +08:00
pnoker 0f1245f00e refactor(driver): centralize http driver json constants 2026-06-12 22:17:08 +08:00
pnoker d2a9547310 refactor(mcp): type auth gateway contracts 2026-06-12 22:15:24 +08:00
pnoker f831cc8c1a refactor(mcp): reuse shared protocol constants 2026-06-12 21:56:35 +08:00
pnoker 2eabf25b85 refactor(mcp): centralize protocol constants and digest helpers 2026-06-12 21:56:24 +08:00
pnoker 7dacc47056 docs(auth): document principal and mcp architecture
Update auth, gateway, architecture, quickstart, changelog, and superpowers design documents for the Principal identity model and OAuth-backed MCP server.
2026-06-12 21:20:41 +08:00
pnoker fbccee8f75 feat(mcp): add oauth-backed gateway runtime
Add OAuth metadata, registration, token, revoke, introspect, MCP catalog, connection, whitelist, and audit runtime in auth.

Expose gateway /.well-known OAuth resource metadata and /mcp JSON-RPC initialize, ping, tools/list, and tools/call with principal forwarding and high-risk call safeguards.
2026-06-12 21:19:58 +08:00
pnoker 35dc46e95f feat(auth): introduce principal identity model
Replace legacy user-login and role-user binding runtime with Principal, LocalCredential, TenantMembership, ServiceAccount, and RolePrincipalBind.

Switch gateway/backend identity propagation to X-Auth-Principal and align agentic/controller security context types with PrincipalHeader.
2026-06-12 21:18:54 +08:00
pnoker 2d255c18be feat: add yuce docs 2026-06-12 11:26:23 +08:00
pnoker 1811d4f8ff fix: support reactive wildcard permissions 2026-06-12 11:26:23 +08:00
pnoker f75003b030 docs(design): add Gateway MCP server design proposal
- Add mcp-server.md: full design for exposing OpenAPI interfaces as MCP
  tools through the gateway, covering architecture, database model,
  permission control (reusing dc3_resource/dc3_role_resource_bind),
  HTTP vs gRPC analysis, dynamic tool refresh, and observability
- Register MCP Service in VitePress sidebar config
- Add entry to design index page
2026-06-12 02:07:43 +08:00
pnoker ec68f0cb7c feat(rabbitmq): expose tls configuration v2026.6.11 2026-06-11 18:03:30 +08:00
pnoker 56d85f7ef3 chore(compose): pass rabbitmq initialization env 2026-06-11 16:01:12 +08:00
pnoker 7a2cc9b8fa chore(compose): streamline environment defaults 2026-06-11 15:04:01 +08:00
pnoker cd6dca6881 chore: add .m2/ to gitignore, DC3_SECURITY_KEY, and minor formatting fixes
- Add .m2/ to .gitignore for workspace-local Maven repository
- Add DC3_SECURITY_KEY to dev environment files
- Fix RoleUserBindController parameter formatting
- Fix README.ja.md newline breaks
2026-06-11 09:15:42 +08:00
pnoker 41e4408ac4 fix(auth): add resource-by-code lookup to prevent sync drift
Add loadResourcesByCodes() to query existing resources by resource_code
key during the sync cycle. When a scanned API maps to an existing resource
that was previously unlinked from the entity, reconcile by updating the
existing row instead of attempting a duplicate insert.
2026-06-11 09:15:23 +08:00
pnoker 5809dfa83f style: complete Swagger import reordering and add OpenAPI @Schema annotations
Finish moving io.swagger.v3.oas.annotations imports to alphabetical position
in remaining auth controllers. Add @Schema descriptions to SessionExt,
BaseVO, and Pages for richer OpenAPI schema generation.
2026-06-11 09:14:59 +08:00
pnoker b4a2f3733a fix(auth): deduplicate resource_code in sync batch to prevent unique constraint violation
Multiple scanned APIs can share the same resource_code when their apiName
values collide (e.g. two dashboard endpoints both resolve to 'dashboard:get').
Previously reconcileLeafResources inserted one resource row per API, which
violated the (resource_code, service_name) unique constraint.

Track seen resource keys with a LinkedHashSet during the insert-phase loop
and skip subsequent APIs that produce an already-seen resource_code.
2026-06-11 00:58:12 +08:00