Repository navigation
Authorise every Party operation by its own policy: commands need the write scope, Retrieve queries the read scope (roadmap 1.15) - #135
Merged
Conversation
… write scopes for Party Reference Data Directory Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…write scope, Retrieve queries the read scope (roadmap 1.15) - One policy per BIAN operation, named by its operation id and registered by the context's host module (AddOperationPolicies: AddCommand / AddQuery); endpoints use RequireOperation(OperationId). - Scopes party-reference-data-directory:read and :write, checked exactly in the space-separated scope claim; 403 shared.forbidden before idempotency, If-Match and 404 checks. - MCP protected-resource metadata lists scopes_supported. - Dev realm declares the operation scopes plus basic (sub), profile and email (no claims), verified against Keycloak 26.6. - ADR 0038; ADR 0014, 0019 and 0022, tech-stack and CONTRIBUTING updated. Closes #40 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Roadmap phase
Phase: 1.15 Authorisation policies
Planning package:
specs/2026-11-09-party-authorisation-policies/Closes #40
Summary
Each Party Reference Data Directory operation now has its own authorisation policy. This meets the quality bar's "authorised per BIAN operation" and the 1.15 follow-ups left by ADR 0019 and ADR 0022.
Scopes (CQRS split)
party-reference-data-directory:write: Register, Update, Demographics Update and Exchange, Reference Update, Associations Register and Update, and BankRelations Update.party-reference-data-directory:read: theRetrieveoperations.shared.forbiddenProblem Details. On a command this comes before theIdempotency-Key400 and theIf-Match428, so nothing is stored. On a query it comes before the 404, so a caller without the read scope cannot probe which records exist.How it is wired
IServiceDomainModule.AddOperationPolicies, withAddCommand(id, WriteScope)orAddQuery(id, ReadScope). The registrations build anOperationPolicyCatalog, and registering an operation twice stops the host.RequireOperation(OperationId)from the root ofRimBank.Api. It names the endpoint, requires the policy and declares the 403.OperationScopeAuthorizationchecks the space-separatedscopeclaim with an exact, case-sensitive match. Its name avoids theHandlersuffix, because Wolverine treats…Handlertypes in the host as message handlers.MCP
scopes_supported.Dev realm
sub, andopenid profile emailis refused. So the realm also declares:basic, holding only thesubmapper;profileandemail, with no claims, so tokens carry no personal data.rimbank-keycloak-datavolume to import the new realm.ADRs and docs
Definition of done
.Subscriptions→.PublishedLanguage. Each context owns its own scopes.shared.forbiddenfrom the existing status-code pages. The MCP tool path comes with the tools in 1.16.docs/adr/for any significant or BIAN-interpretation decision (ADR 0038)Validation
dotnet restore RimBank.slnx --locked-mode: OK, no lock file changes.dotnet build RimBank.slnx -c Release: 0 warnings, 0 errors.dotnet test --solution RimBank.slnx -c Release --no-build: 2070 passed, 0 failed, 0 skipped.dotnet format RimBank.slnx --verify-no-changes: exit 0.New tests:
RimBank.Host.TestsSecurity/OperationPolicyTests:shared.forbidden;RimBank.Host.TestsMcp/McpAuthorizationTests:scopes_supportedlists the policy scopes, and the list is empty when no module registers a policy.RimBank.Api.TestsParty/…/AuthorisationTests(Testcontainers), for all 13 operations:RimBank.Api.TestsOperationAuthorizationCoverageTests(the guard):GETis a query on the read scope, and every other verb a command on the write scope;RimBank.AppHost.TestsModel/DevRealmTests:basicholds thesubmapper only, andprofileandemailhave no mappers.OpenApiDocumentTestsnow expects the declared 403.Manual check, beyond
validation.md: I imported the realm into a throwaway Keycloak 26.6.rimbank-dev-clientclient-credentials token carriessub,azp,aud=rimbank-apiand both scopes.rimbank-mcp-clientuser token, requested with no scope or withopenid profile email, carriessub, both scopes and no profile or email claims.Review focus
Associations/Register, …). They share the host-wide namespace of endpoint names, and a clash stops the host at startup. Should they carry the service domain as a prefix now?basic,profileandemailitself.roles,web-origins,acr,addressandphoneare gone, andoffline_accessis refused for the dev user, so MCP clients sign in again when the token expires.OperationPoliciesregistration, notAuthorizationBuilder. No OpenAPIsecurityrequirement was added. Both are recorded in the requirements file.🤖 Generated with Claude Code