Commit Graph
142 Commits
Author SHA1 Message Date
Henry ZhangandClaude Fable 5 98d8eb80b1 refactor(api): type OAuth grant_type as proto enum (#198)
grant_type in GrpcMcpIntrospectDTO was a free-form string. Introduce
GrpcOAuthGrantType (GRPC_OAUTH_GRANT_TYPE_UNSPECIFIED / AUTHORIZATION_CODE
/ CLIENT_CREDENTIALS / REFRESH_TOKEN). Enum names are upper-case (Java
enum constants must be); the boundary converts to/from the lowercase
OAuth spec form (authorization_code) via toUpperCase / toLowerCase.
BO, DB and OAuth form parameter stay lowercase string.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-06 19:03:50 +08:00
Henry ZhangandClaude Fable 5 3f78487357 refactor(api): type MCP audit status as proto enum (#197)
audit status in GrpcMcpAuditCommand was a free-form string. Introduce
GrpcMcpAuditStatus (MCP_AUDIT_STATUS_UNSPECIFIED / SUCCESS / DENIED /
POLICY_DENIED / ERROR / UNKNOWN) — names match McpAuditStatusEnum values.
Server maps proto->DTO via name(); facade maps BO string->proto via
toGrpcAuditStatus. BO and DB stay string.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-06 18:21:20 +08:00
Henry ZhangandClaude Fable 5 4a69185d97 refactor(api): type MCP principal_type as proto enum (#196)
principal_type was a free-form string in GrpcMcpIntrospectDTO and
GrpcMcpAuditCommand. Introduce GrpcMcpPrincipalType
(MCP_PRINCIPAL_TYPE_UNSPECIFIED / USER / SERVICE_ACCOUNT / SYSTEM) —
names match PrincipalTypeEnum values, so the mapping is a direct
valueOf / name(). Server + facade convert at the proto boundary; BO,
gateway and HTTP header layer stay string.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-06 18:00:45 +08:00
Henry ZhangandClaude Fable 5 3a03962600 refactor(api): type MCP risk_level as proto enum (#195)
risk_level was a free-form string across GrpcMcpToolMetadataDTO,
GrpcMcpToolResolveDTO, GrpcMcpToolAuthorizeDTO and GrpcMcpAuditCommand.
Introduce GrpcMcpRiskLevel (MCP_RISK_LEVEL_UNSPECIFIED / LOW / MEDIUM /
HIGH) — names match McpRiskLevelEnum values, so the mapping is a direct
valueOf / name(). Server + facade convert at the proto boundary; the BO
and DB layer stay string.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-06 17:24:18 +08:00
Henry ZhangandClaude Fable 5 7c643a8e80 fix(api): dc3-api contract overhaul (auth JWT, history, presence, decision enum) (#193)
* fix(api): correct inverted enable_flag comment and document time unit

- tenant.proto enable_flag comment said "1 enabled, 0 disabled" but the
  actual EnableFlagEnum is ENABLE=0, DISABLE=1 — callers reading the
  comment would invert the flag. Correct it.
- base.proto create_time/operate_time are epoch milliseconds
  (LocalDateTimeUtil/Instant.toEpochMilli); document the unit so callers
  don't guess seconds vs millis.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(api): carry timestamp in point-value history; explicit bool presence

#5 Point-value history: the whole chain (proto -> gRPC server ->
PointValueService -> repository -> facades -> controller -> agentic tool)
returned List<String> and dropped create_time even though the DB row
already carried it. Switch to PointValueBO / FacadePointValueBO end to
end so callers receive each value with its timestamp.

#6 Field presence: GrpcR.ok and McpIntrospectDTO.active are now optional
bool, so "unset" is distinguishable from false on the wire.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(auth): unify JWT signing key, drop salt/password from token contract

The JWT signing key was per-principal — securityKey + ":" + salt, where
salt was the credential salt also carried through the gateway and the
token RPC. That makes the JWT key weak and widens salt exposure to every
gateway hop. Sign with the single configured securityKey (HS256) instead
and remove salt from the JWT path entirely:

- KeyUtil.generateToken/parserToken drop the salt parameter; the HMAC
  key is now just securityKey (must be >= 32 bytes for HS256).
- TokenService.generateToken/checkValid drop the salt parameter.
- token.proto GrpcLoginQuery drops salt and password — CheckValid only
  ever needed tenant, name and token.
- gateway FilterService, TokenGrpcFacade, TokenController adapted; the
  request header no longer feeds salt into validation.

The login-handshake salt (POST /token/salt, used to salt the password
client-side before verifyPassword) is unchanged — only the JWT signing
salt is removed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(api): type MCP authorize decision as proto enum

The authorize-tool-call decision was a free-form string, so callers
could only compare it against literals with no compile-time check.
Introduce GrpcMcpDecision (MCP_DECISION_UNSPECIFIED / AUTHORIZED /
CONFIRM_REQUIRED / REJECTED) and type GrpcMcpToolAuthorizeDTO.decision
with it. Enum names match the existing auth-side literals, so the
mapping is a direct valueOf / name().

- McpRuntimeServer builds the enum via toGrpcDecision (unknown -> UNSPECIFIED).
- McpRuntimeGrpcFacade maps enum -> BO string via name().
- gateway unchanged: it receives the BO (string decision) through the facade.

The other string MCP fields (risk_level, status, grant_type,
principal_type) stay strings for now — their value sets are wider and
partly lowercase (OAuth grant_type), so they are a follow-up.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(facade): align TokenLocalFacade with 3-arg checkValid (CI compile fix)

TokenLocalFacade (local impl) was missed when TokenFacade.checkValid
dropped salt; CI compiles facade-local-auth independently and caught
it. Align it + its test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-06 16:36:35 +08:00
pnokerandClaude 77a20466bc refactor(api): reorganize proto files from center to common package
- Move proto files from api/center/ to api/common/ for auth, data, manager modules
- Update java_package and java_outer_classname in moved proto files
- Add GrpcDriverQuery message to shared query.proto in dc3-common-api
- Move GrpcDriverQuery proto from common.driver to common package
- Update Java imports referencing relocated proto messages
- Remove redundant pom.xml metadata (developers, licenses, scm, version)
  from api submodules — inherited from parent

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-09 12:43:48 +08:00
pnoker abd826bf6e docs(api): correct gRPC RPC names, import paths, and missing services
Align the four api READMEs with the actual protos: Select*->Get*/List*
per the CRUD verb convention, fix api/common->api/center import paths
for auth/data, drop the fabricated manager SelectByServiceName RPC, and
document the previously omitted auth/data/manager services.
2026-06-22 16:49:07 +08:00
pnoker b80909565e refactor(auth): remove legacy scanner-sourced x-dc3-ai path end-to-end 2026-06-19 01:07:13 +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
pnoker 8ea0c0faf3 refactor(mcp): route runtime calls through facade 2026-06-12 22:38:30 +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 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 fe766350b9 fix(auth): enforce cross-service permissions 2026-06-10 20:36:58 +08:00
Vickey 918b3d5e8e feat: update pom version to 2026.5.22 2026-05-26 00:30:11 +08:00
Vickey 476799e513 refactor(api): rename gRPC SelectBy* RPCs to GetBy*/ListBy*
Apply the new naming convention to .proto contracts so the verb on
each RPC reflects the cardinality of its result:

  - get*  for single-record returns (RPCs returning a single DTO)
  - list* for multi-record returns (RPCs returning a Page or List DTO)

23 RPCs renamed across 9 .proto files. Returns-single -> Get*:
  user.proto                 SelectById        -> GetById
  user_login.proto           SelectByName      -> GetByName
  tenant.proto               SelectByCode      -> GetByCode
  driver_device.proto        SelectById        -> GetById
  driver_point.proto         SelectById        -> GetById
  manager_point.proto        SelectById        -> GetById
  manager_device.proto       SelectByDeviceId  -> GetByDeviceId
  manager_driver.proto       SelectByDriverId  -> GetByDriverId
  manager_driver.proto       SelectByDeviceId  -> GetByDeviceId
  manager_profile.proto      SelectByProfileId -> GetByProfileId

Returns-multi -> List*:
  driver_device.proto        SelectByPage         -> ListByPage
  driver_point.proto         SelectByPage         -> ListByPage
  manager_device.proto       SelectByPage         -> ListByPage
  manager_device.proto       SelectByDriverId     -> ListByDriverId
  manager_device.proto       SelectByProfileId    -> ListByProfileId
  manager_device.proto       SelectByDeviceIds    -> ListByDeviceIds
  manager_driver.proto       SelectByPage         -> ListByPage
  manager_driver.proto       SelectByDriverIds    -> ListByDriverIds
  manager_point.proto        SelectByPage         -> ListByPage
  manager_point.proto        SelectByIds          -> ListByIds
  manager_profile.proto      SelectByPage         -> ListByPage
  manager_profile.proto      SelectByProfileIds   -> ListByProfileIds
  manager_profile.proto      SelectByDeviceId     -> ListByDeviceId

This is a wire-level breaking change: gRPC clients and servers must
upgrade in lockstep. Server impls, facade clients, and Java callers
are aligned in subsequent commits.
2026-05-18 19:19:40 +08:00
pnoker 7f5da1a0f8 chore: bump version to 2026.5.18 across all modules 2026-05-18 00:24:22 +08:00
pnoker 994ccba991 docs: update READMEs and project documentation
Refresh module READMEs, AGENTS.md, CONTRIBUTING.md, and dc3/doc/
guides to reflect the unified Dockerfile, consolidated compose stacks,
and updated build instructions.
2026-05-17 19:03:21 +08:00
pnoker 996518186a build: bump version to 2026.5.17
Update parent version and dc3.version from 2026.5.5 to 2026.5.17
across all Maven modules.
2026-05-17 19:01:44 +08:00
pnoker e47299a327 chore: remove format and format-check targets from Makefile 2026-05-07 23:55:32 +08:00
pnoker 95c40b2387 chore: bump version to 2026.5.5
Roll every pom, per-module README, Spring banner, and @version /
@since javadoc tag from 2026.4.30 to the new 2026.5.5 release line.
2026-05-05 00:56:09 +08:00
Vickey 706917dd2e feat(auth): add api_group to cluster endpoints by owning controller
Thread a new api_group field end-to-end through the scanner, gRPC/local
facade, proto, auth entity layer, and registry sync service. Populated
from handler.getBeanType().getSimpleName() (e.g. ApiController), this is
the foundation for the forthcoming resource-tree hierarchy grouping
sibling endpoints under their controller.
2026-05-01 17:30:02 +08:00
pnoker ddac60f4f7 refactor(auth): drop tenant from registry resources 2026-05-01 16:33:17 +08:00
Vickey fb9ee53781 feat: auto-register center API endpoints to auth resource tables
Adds a startup-time registrar that scans the local WebFlux handler mappings
of each center service and reconciles the discovered endpoints against
dc3_api and dc3_resource (insert-if-missing, update-if-drifted, soft-delete-
if-orphaned), so the permission model is no longer hand-maintained.

Wiring:
- dc3-common-resource-registrar (new module): scanner, diff runner, Spring
  Boot AutoConfiguration. Activates on ApplicationReadyEvent.
- dc3-common-facade-api: ResourceRegistryFacade + BOs define a transport-
  neutral sync contract.
- dc3-common-facade-local / dc3-common-facade-grpc: two implementations
  selected via dc3.facade.mode. center-auth/single use local; manager/data
  call auth via gRPC.
- dc3-common-auth: biz-side ResourceRegistrySyncService performs the three-
  way diff inside a transaction guarded by pg_advisory_xact_lock(hashtext
  (serviceName)); exposes ResourceRegistryApi gRPC server.
- dc3-api-auth: new resource_registry.proto contract.
- ApiDO/BO/VO/Query gain a serviceName field so each service's endpoints
  can be located with a single indexed lookup.

Deployment-visible changes:
- api_code format is the human-readable serviceName:METHOD:/path
- dc3_resource.resource_code format is api:serviceName:METHOD:/path
  (prefixed namespace reserved for future resource types)
- center-auth application.yml sets dc3.facade.mode=local
- 4 center pom.xml files pull in the registrar (auth also gets facade-local)
2026-04-30 21:40:45 +08:00
Vickey 200beeaa71 chore: update version to 2026.4.30 in multiple files 2026-04-30 16:06:30 +08:00
pnoker c5a9feeeb9 feat: add .env file for Docker Compose configuration and update usage instructions 2026-04-29 10:27:57 +08:00
pnoker ea17c86387 chore: update version to 2026.4.19 across all modules and adjust branch settings in codeql.yml 2026-04-19 13:45:21 +08:00
pnoker a1514061b4 fix: revert proto package to api.common.* to fix build breakage
Proto3 type resolution walks up the package hierarchy. After changing
package api.common.auth/data/manager to api.center.*, unqualified
references like GrpcR/GrpcBase (defined in api.common) can no longer
be resolved, causing PROTOC compile errors.

Revert package declarations to api.common.auth/data/manager while
keeping java_package as io.github.pnoker.api.center.* — java_package
is independent from proto package and controls Java output only.
2026-04-18 02:05:36 +08:00
pnoker 0833a88115 fix: complete dc3-api proto optimization
1. manager_point.proto: add missing SelectById RPC and GrpcRPointDTO
   response message to match driver_point.proto symmetry

2. Rename java_outer_classname to include module prefix to avoid
   confusion between driver and manager modules:
   - driver: DeviceProto→DriverDeviceProto, DriverProto→DriverRegistrationProto,
     EntityProto→DriverEntityProto, PointProto→DriverPointProto,
     QueryProto→DriverQueryProto, QueryPageProto→DriverQueryPageProto
   - manager: DeviceProto→ManagerDeviceProto, DriverProto→ManagerDriverProto,
     PointProto→ManagerPointProto, QueryProto→ManagerQueryProto,
     QueryPageProto→ManagerQueryPageProto

3. Reorganize proto files into subdirectories matching proto package:
   - auth:    src/main/protobuf/api/center/auth/
   - data:    src/main/protobuf/api/center/data/
   - driver:  src/main/protobuf/api/common/driver/
   - manager: src/main/protobuf/api/center/manager/
   Update all intra-module imports to use full absolute paths
2026-04-18 01:51:07 +08:00
pnoker 4ebde7cec0 fix: optimize dc3-api pom element order and proto files
- dc3-api/pom.xml: move <profiles> to after <build> per Maven POM
  standard element ordering; move <dependencyManagement> before
  <dependencies>
- driver_device.proto: rename driverConfigs/pointConfigs to
  driver_configs/point_configs (proto3 snake_case convention)
- auth/data/manager protos: align package declaration from
  api.common.xxx to api.center.xxx to match java_package option
- driver_entity.proto, driver_query.proto, driver_query_page.proto,
  manager_query_page.proto: remove trailing blank lines
2026-04-18 01:41:47 +08:00
pnoker d102e18b00 chore: fix inceptionYear and scm connection in all pom.xml
- Fix <inceptionYear> from '2016-2022' to '2016' in 20 pom.xml files
- Fix <scm> connection/developerConnection to use scm:git: prefix in 22 pom.xml files
2026-04-18 01:31:07 +08:00
pnoker e57793ec5f chore: bump version to 2026.4.18.3 and optimize pom.xml dependencies
- Bump all module versions from 2025.11.1 to 2026.4.18.3
- Remove orphaned dc3-common-influx dependency and property from root pom.xml
- Standardize dependency comment style in dc3-common/pom.xml
- Merge gRPC dependency groups into single section in dc3-common-api
- Restructure Spring Integration MQTT and Eclipse Paho groups in dc3-common-mqtt
- Fix incorrect comment 'DC3 Common Exception' to 'DC3 Common Related' in dc3-common-postgres
- Add missing blank line before </dependencies> in dc3-common-driver
- Remove stray blank line in root pom.xml dependencyManagement
2026-04-18 01:05:30 +08:00
Vickey 78a612c4ac feat: add JavaDoc comments and enhance field naming consistency across project 2026-01-07 17:07:46 +08:00
Vickey 025a7b348f chore: update copyright headers and minor proto field comments across modules 2026-01-07 15:19:43 +08:00
Vickey 8a22940eb9 Merge remote-tracking branch 'origin/develop' into develop
# Conflicts:
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/PrefixConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/QueryWrapperConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/RequestConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/SuffixConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/SymbolConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/TimeConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/enums/DeviceEventTypeEnum.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/enums/DeviceStatusEnum.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/enums/EnableFlagEnum.java
2026-01-07 15:19:02 +08:00
zzi666 578739f338 refactor(proto): simplify proto comments, remove redundant README files, and unify format 2025-12-31 14:15:29 +08:00
zzi666 7c6b9e3ea3 Merge branch 'develop' of github.com:pnoker/iot-dc3 into develop 2025-12-31 10:07:38 +08:00
Vickey 557152226c docs(api): add README files for auth, data, and driver API modules 2025-12-28 19:23:20 +08:00
Vickey 0e419bab05 feat: update pom 2025-11-11 13:22:24 +08:00
zzi666 eafe3e14a4 refactor: standardize and translate comments across Protobuf files and environment script for clarity and consistency 2025-11-06 16:37:35 +08:00
zzi666 ff3fc9e521 refactor: standardize and translate comments across Protobuf files, Java services, and configuration classes for consistency and clarity 2025-10-27 19:43:19 +08:00
zzi666 73fe41091e refactor: standardize descriptions, comments, and documentation across POM files and Protobuf definitions 2025-10-24 20:07:28 +08:00
zzi666 137a0f89e0 refactor: standardize protobuf annotations and document translations 2025-10-24 15:45:50 +08:00
Vickey a9e8d05631 feat: update version 2025-10-05 17:16:37 +08:00
Vickey 7302107c56 chore: bump all module versions to 2025.9.2 2025-09-11 17:02:24 +08:00
Vickey 2051d42847 refactor(common): remove hutool dependency and replace usages with native utilities 2025-09-11 14:57:02 +08:00
Vickey 8cc7365293 build: bump all module versions to 2025.6.6 and update compose image tags 2025-08-26 22:38:53 +08:00
Vickey 022bab4fbd chore: switch license declaration from Apache-2.0 to AGPL-3.0 across all poms 2025-08-26 22:16:35 +08:00
Vickey a39d2fb533 chore: migrate license headers from Apache 2.0 to AGPL-3.0 across all source files 2025-08-26 22:01:24 +08:00
Vickey 4d147af22e feat(common-driver): extend protobuf schemas and refactor driver service implementations 2025-08-09 13:23:18 +08:00
Vickey f415207088 build: bump project version to 2025.6.5 across all modules 2025-07-15 14:58:51 +08:00