feat: author and inspect grpc data connections

This commit is contained in:
Joseph Doherty
2026-11-16 20:58:43 -05:00
parent 8ad03e9c5d
commit 1df29a3124
31 changed files with 1246 additions and 141 deletions
+39 -10
View File
@@ -27,7 +27,7 @@ OtOpcUa has four independent security concerns. This document covers all four:
1. **Transport security** — OPC UA secure channel (signing, encryption, X.509 trust).
2. **OPC UA authentication** — Anonymous / UserName / X.509 session identities. A UserName token is an **API key** (username literally `apikey`, password `otua_<keyId>_<secret>`) verified by peppered HMAC — **LDAP backs Admin UI login only** since #520 (2026-08-01).
3. **Data-plane authorization** — who can do what on an OtOpcUa endpoint. ⚠️ Governed by **one flag** (#520 stages 5–6, 2026-08-01). With `Security:Acl:Enabled` **false — the default** — the only enforcement is two coarse, server-wide role gates (`WriteOperate` on Value writes, `AlarmAck` on the alarm methods), and Read, Browse, Subscribe and HistoryRead are **ungated** for any admitted session. With it **true**, scoped `NodeAcl` grants (the `PermissionTrie` subsystem) decide **every** data-plane operation — read, browse, subscribe, write, alarm commands and HistoryRead — *replacing* the server-wide roles. See [Data-Plane Authorization](#data-plane-authorization).
3. **Data-plane authorization** — who can do what on an OtOpcUa endpoint. ⚠️ Governed by **one flag** (#520 stages 5–6, 2026-08-01). For locally owned nodes with `Security:Acl:Enabled` **false — the default**, write/alarm enforcement uses coarse, server-wide role gates (`WriteOperate` on Value writes, `AlarmAck` on the alarm methods), and Read, Browse, Subscribe and HistoryRead are **ungated** for any admitted session. With it **true**, scoped `NodeAcl` grants (the `PermissionTrie` subsystem) decide **every** data-plane operation — read, browse, subscribe, write, alarm commands and HistoryRead — *replacing* the server-wide roles. Mapped data and gRPC exports always require scoped authorization independently of that flag; HistoryUpdate has its own mutation gate. See [Data-Plane Authorization](#data-plane-authorization).
4. **Control-plane authorization** — who can view or edit fleet configuration in the Admin UI. Gated by the `AdminRole` (`Viewer` / `Designer` / `Administrator`) claim resolved from `LdapGroupRoleMapping`.
Transport security and OPC UA authentication are per-node concerns configured in the Server's bootstrap `appsettings.json`. Data-plane ACLs and Admin role grants live in the Config DB.
@@ -144,7 +144,7 @@ The Admin UI `Certificates.razor` page (`src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Co
### Internal gRPC planes (h2c) — accepted cleartext posture
Everything above concerns the **OPC UA** endpoint — the surface external clients bind to. OtOpcUa
also runs **five internal gRPC planes** between its own processes (central ↔ driver node, and node ↔
also runs **five legacy internal gRPC planes** between its own processes (central ↔ driver node, and node ↔
pair partner). Those are a separate transport story, recorded here so it is written down once rather
than rediscovered per plane.
@@ -192,7 +192,7 @@ assumption is wrong:
fleet-wide key with extra steps. The three literal `dev-mesh-psk-*` keys exist only on the
docker-dev rig.
**Future work.** The recorded alternative is a `UseTls`/scheme option on these planes (dial `https://`,
**Future work for these five legacy planes.** The recorded alternative is a `UseTls`/scheme option on these planes (dial `https://`,
bind the listener with a certificate). If it is ever built it **must cover all five planes together**
— a mixed posture, where some internal links are encrypted and others are not, is harder to reason
about than either uniform answer, and invites exactly the "which one was it again?" mistake this note
@@ -200,6 +200,34 @@ exists to prevent. See issue #545.
---
## Data-connection transport and mapped authority
The current-data gRPC service is a separate plane with a dedicated HTTP/2 listener. Production
requires TLS, an explicit allowed-host list and authenticated target cluster/node policy. Its
Development-only cleartext exception requires a literal loopback listener. The accepted h2c posture
of the five legacy mesh planes above does not apply to data connections and does not change them.
See [Configuration](Configuration.md#dataconnections).
Origin exports grant named authenticated principals access to explicit Raw/UNS roots. Consumer
connections use independently provisioned target credentials, canonical `secret:data/...`
references and independently versioned trust roots. Applied artifacts carry references and explicit
consumer scopes rather than credential values. Credential and trust bundle mounts are node-local;
scope/version validation, explicit deletion and retirement prevent an old bundle from restoring
retired authority. Missing mounts are retried and are not themselves deletion requests.
Mapped access is always authorized, including when `Security:Acl:Enabled=false`. It requires the
intersection of local mapped-view grants, connection/mapping operations and origin export grants,
plus current identity, metadata lease and serving provenance. Mapped descendants are resolved from
the trusted live catalog; their opaque identifiers must not fall back to local path-based grants.
Read/browse/subscription admission and final value delivery retain current authority checks. Writable
metadata alone does not confer write-through, and secondary/read-replica access never confers writes.
The flag-off descriptions below concern locally owned nodes. They are not a bypass for gRPC export
or mapped nodes. Remote projected branches cannot be re-exported as locally owned data, and remote
history, alarm/event and relay operations are not part of this contract. Authorized imported current
values can feed local derived engines. See [Data connections](DataConnections.md) and
[Read/write operations](ReadWriteOperations.md).
## OPC UA Authentication
The Server accepts three OPC UA identity-token types:
@@ -582,8 +610,9 @@ the one request making it. One key remains:
### What is enforced with the flag off
There are exactly **three** authorization checks in the whole OPC UA server layer. All three are
coarse, **server-wide role string checks** with no per-node component.
For locally owned nodes, the legacy write/alarm gates below are coarse, server-wide role checks.
HistoryUpdate also has its own mutation gate. Mapped nodes always use scoped authority, as described
[above](#data-connection-transport-and-mapped-authority).
| Operation | Gate | Requires |
|---|---|---|
@@ -620,10 +649,10 @@ write and each Part 9 method call first asks `DataPlaneAuthorizer.AuthorizeKeyUs
check reads the deployed snapshot, which is also what the flag-on path has always done. Deploy after
minting a key.
**What has no authorization check at all:**
**Local operations left permissive with the flag off:**
- **Read, Browse, TranslateBrowsePaths** — no override, no handler. Any admitted session, including
an Anonymous one, sees and reads the entire address space.
- **Read, Browse, TranslateBrowsePaths** — local-node ACL filtering is bypassed; admitted sessions,
including Anonymous, can access locally owned nodes. The overrides still enforce mapped authority.
- **HistoryRead** — all four overrides (`HistoryReadRawModified`, `HistoryReadProcessed`,
`HistoryReadAtTime`, `HistoryReadEvents`) run without an identity check.
- **CreateMonitoredItems / subscriptions / TransferSubscriptions**.
@@ -1331,8 +1360,8 @@ HistoryUpdate rewrites recorded history, so unlike HistoryRead it is gated **wha
(`src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/Security/DataPlaneAuthorizer.cs`, registered in
`Host/Program.cs`, consulted by `OtOpcUaNodeManager`) calls `Authorize` at every data-plane seam —
read, browse, subscribe, write, alarm commands and HistoryRead — **when `Security:Acl:Enabled` is
true**. With the flag **off (the default)** the authorizer is constructed but not consulted, and the
effective posture for Read/Browse/Subscribe/HistoryRead is default-ALLOW (see
true**. With the flag **off (the default)** local Read/Browse/Subscribe/HistoryRead remain permissive;
mutation key-usability checks and mapped-data authorization still consult the authorizer/policy (see
[What is enforced with the flag off](#what-is-enforced-with-the-flag-off)).
Properties of the wired path: