Repository navigation
Conversation
6 of 10 tasks
This branch has not been deployed
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.
Ready for review checklist:
Summary
Reuse existing installation-scoped
Role.Observer.<CODE>application permissions, including existing analysis feedback submission/update. No new role or authorization policy. Add explicit request-level narrowing so Flotilla can safely proxy inspection data for a device whose installations are a subset of its backend application's grants.This supersedes the earlier tests/docs-only scope: a backend token with Observer.KAA+NLS plus the existing
InstallationCode=KAAsubstring filter still authorizes a nested analysis shared by KAA and NLS. Merely checking the returned root installation or partially populated nested navigation collections cannot safely establish device-scoped authorization.Companions: equinor/flotilla#3197 and equinor/robotics-infrastructure#1501.
API contract
Optional repeated
InstallationScopequery parameters are supported ONLY on:GET /api/inspection-recordGET /api/inspection-record/id/{id}GET /api/inspection-record/inspection-id/{inspectionId}Example:
?InstallationScope=KAA&InstallationScope=NLS. Each code must contain exactly three ASCII letters or digits; codes normalize to uppercase, deduplicate and sort. Empty/malformed/comma-separated values return 400. Any requested installation outside the caller's Observer grants returns 403 rather than silently intersecting. Admin may request any valid installation, but its global-access fast paths cannot bypass explicit narrowing.The same scope constrains outer records and every linked inspection of each nested analysis, before AnalysisTypes filtering, count/pagination, DTO construction or SAS generation. Omitted scope preserves current callers; existing InstallationCode substring filtering can only further narrow results. Scoped detail reads retain existing missing-record behavior: Observer 403, Admin 404.
Successful explicitly scoped responses, including empty lists, emit
X-Inspection-Installation-Scopewith the sorted unique uppercase comma-separated requested scope. Unscoped/rejected requests do not receive acknowledgement. Flotilla must derive query values from authenticated device grants, reject missing/mismatched acknowledgement (including older SARA deployments silently ignoring the query), and verify returned root installation codes. The scope is a narrowing mechanism, not a new identity assertion or grant.All other endpoint policies remain unchanged. Observer feedback stays allowed within its authorized installations; this change adds no feedback scope contract or proxy. Inspection creation/deletion, adding analyses and feedback deletion remain Admin-only. The earlier proposed ReadOnly role was removed in a normal follow-up commit; history was not rewritten.
Validation
dotnet test --project api.Tests/api.test.csproj --no-restore --filter 'FullyQualifiedName~InspectionApplicationAccessTests|FullyQualifiedName~AnalysisRunControllerTests|FullyQualifiedName~FeedbackControllerTests|FullyQualifiedName~InspectionMeasurementControllerTests' --verbosity quiet --no-progress— passed, 27 tests.dotnet test --project api.Tests/api.test.csproj --no-build --filter 'FullyQualifiedName~InspectionRecordServiceTests|FullyQualifiedName~AuthenticationConfigurationsTests|FullyQualifiedName~ProtectedEndpointsTests|FullyQualifiedName~BlobStorageServiceTests' --verbosity quiet --no-progress— passed, 48 tests.dotnet csharpier check api/Controllers/InspectionRecordController.cs api/Services/InspectionRecordService.cs api/Services/InstallationAccess.cs api.Tests/Controllers/InspectionApplicationAccessTests.cs api.Tests/Mocks/BlobStorageServiceMock.cs— passed.git diff --check— passed before commit.Tests use locally signed app-only JWTs with roles and no delegated scope through the real JWT bearer handler/claim mapping, replacing only issuer/signing trust. They cover existing Observer reads/feedback, Admin-only mutation denial, and explicit narrowing for both a multi-installation Observer and Admin. Shared-analysis tests verify counts exclude records whose only matching analysis crosses the requested scope, all three endpoints omit mixed results/runs/SAS, and the blob fake records no SAS generation for excluded analyses. Additional cases cover acknowledgement, omitted scope, duplicate/lowercase/multiple codes, unauthorized/malformed values, conflicting root filters and detail denial.
External prerequisites and review context
Ensure existing
Role.Observer.<CODE>app roles includeApplicationinallowedMemberTypeson each actual SARA resource registration, then assign only approved installations to the Flotilla backend service principal. Confirm identifier URI, role IDs, audience and deployment-specific assignments externally. No new ReadOnly roles are needed, no resource IDs are invented, and no grants are applied here. Acquire an application token for the confirmed resource's/.default, not delegateduser_impersonation. Do not grantRole.Adminfor dashboard inspection reads or analysis feedback.Flotilla verifies its opaque device credentials and enforces device grants. Existing inspection image SAS URLs grant blob reads for one hour, independently of device revocation. Live tenant grants and deployed end-to-end flows are not verified by these local tests.
No existing issue was supplied for this milestone. External provisioning and end-to-end verification remain outstanding and have not been filed as issues, so the corresponding checklist items remain unchecked. Keep this PR draft for team discussion; no deployment, permission grant or merge is part of this change.