Enforce KeyCredential authorization and ownership (OPC 10000-12 §§8.5.5-8.5.7)#4054
Enforce KeyCredential authorization and ownership (OPC 10000-12 §§8.5.5-8.5.7)#4054marcschier wants to merge 3 commits into
Conversation
….5-8.5.7) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR enforces OPC UA GDS KeyCredential authorization and ownership requirements by adding role/privilege checks, binding KeyCredential requests to the initiating SecureChannel client certificate, and persisting immutable application ownership identifiers.
Changes:
- Added
KeyCredentialAdminrole plus authorization helpers and updated tests/fixtures to cover admin/self-admin/app-admin behavior and certificate fingerprinting. - Extended KeyCredential request store APIs to support client-certificate binding and immutable application ownership, and updated the in-memory store accordingly.
- Updated KeyCredential audit event reporting to redact exception details and added conformance tests for application URI resolution and pending-finish status codes.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Opc.Ua.Gds.Tests/KeyCredentialRequestStoreTests.cs | Adds tests for request binding, ownership, and legacy-store compatibility behavior. |
| tests/Opc.Ua.Gds.Tests/KeyCredentialConformanceTests.cs | New conformance tests for app URI resolution and finish result status mapping. |
| tests/Opc.Ua.Gds.Tests/GdsTestFixture.cs | Adds KeyCredentialAdmin role to the test server role list. |
| tests/Opc.Ua.Gds.Tests/AuthorizationHelperTests.cs | Adds tests for new KeyCredential authorization and certificate fingerprint hashing. |
| tests/Opc.Ua.Gds.Tests/AuditEventsTests.cs | Verifies KeyCredential audit failures redact exception details. |
| src/Opc.Ua.Gds.Server.Common/RoleBasedUserManagement/GdsRole.cs | Introduces the KeyCredentialAdmin role definition. |
| src/Opc.Ua.Gds.Server.Common/RoleBasedUserManagement/AuthorizationHelper.cs | Adds KeyCredential role sets and client certificate fingerprint extraction. |
| src/Opc.Ua.Gds.Server.Common/IKeyCredentialRequestStore.cs | Extends store contracts for binding/ownership and updates in-memory store implementation. |
| src/Opc.Ua.Gds.Server.Common/Diagnostics/AuditEvents.cs | Adds exception redaction support for KeyCredential audit events. |
| src/Opc.Ua.Gds.Server.Common/ApplicationsNodeManager.cs | Enforces authorization/ownership/binding for KeyCredential Start/Finish/Revoke and adds resolution helpers. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4054 +/- ##
===========================================
- Coverage 73.55% 30.62% -42.93%
===========================================
Files 1345 1063 -282
Lines 180036 143925 -36111
Branches 31677 26422 -5255
===========================================
- Hits 132427 44083 -88344
- Misses 36911 94144 +57233
+ Partials 10698 5698 -5000
🚀 New features to boost your workflow:
|
Description
This PR splits the GDS KeyCredential changes from #4021.
Specification
StartRequestto use an encrypted SecureChannel and a Client with theKeyCredentialAdminRole,ApplicationAdminPrivilege, orApplicationSelfAdminPrivilege. TheApplicationUrimust uniquely identify an application known to the GDS.FinishRequestto use the same SecureChannel Certificate asStartRequest, and definesBad_RequestNotCompletefor a pending request.Revokeand definesBad_InvalidArgumentfor an unknown credential.Failure
The KeyCredential methods previously verified only an authenticated encrypted SecureChannel. They did not enforce the specification's administrative Role or application-scoped Privileges, persist immutable application ownership, or bind
FinishRequestto the initiating Client certificate. A pending request returnedBadNothingToDo, invalid ownership lookups used non-conformant status codes, and failure audit text could expose exception details.Fix
KeyCredentialAdmin,ApplicationAdmin, andApplicationSelfAdminpermissions, including application scoping.ApplicationUrito exactly one registered application and persist its immutableApplicationId.BadRequestNotCompletefor pending requests and conformant invalid-argument results for unknown request or credential identifiers.Validation
Opc.Ua.Gds.Tests: net10.0 (1053 passed, 42 skipped), net48 (858 passed, 237 skipped).KeyCredentialRequestStoreTests: net10.0 (16 passed), net48 (16 passed).git diff --checkpassed.Related Issues
Checklist
Only verified claims are checked.