Repository navigation
fix(location): authorize endpoint compat detail routes via product/finding - #16377
Merged
Merged
Conversation
…nding The V3 /api/v2/endpoints/<id>/ and /api/v2/endpoint_status/<id>/ routes are served by the compatibility viewsets over LocationProductReference / LocationFindingReference join rows. Their shared UserHasLocationRefPermission handed the raw join row to the authorization layer, which resolves products, findings and locations but not these join rows, so the object-permission check raised NoAuthorizationImplementedError (HTTP 500) for every authorized non-superuser reaching a detail route. A superuser short-circuits the check and an unauthorized user is filtered out by the viewset queryset, which is why the fault stayed hidden until a plain product member opened a detail route. Resolve the row to its product (LocationProductReference) or finding (LocationFindingReference) before the check, mirroring the native Location(Product|Finding)ReferencePermission classes so both the OSS and Pro authorization layers receive an object they already handle. Add a regression test covering both detail routes for an authorized non-superuser. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNVqniCYTXeyUZJoLF7BT2
blakeaowens
approved these changes
Oct 17, 2026
devGregA
approved these changes
Oct 17, 2026
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.
Description
Fixes an HTTP 500 on the V3 endpoint-compatibility detail routes (
GET /api/v2/endpoints/<id>/andGET /api/v2/endpoint_status/<id>/, active whenV3_FEATURE_LOCATIONSis enabled).These routes are served by the compatibility viewsets in
dojo/location/api/endpoint_compat.py, whose rows areLocationProductReference/LocationFindingReferencejoin rows. The sharedUserHasLocationRefPermissionobject-permission class passed the raw join row straight to the authorization layer.user_has_permissionresolves products, findings and locations, but not these join rows, so the object-permission check raisedNoAuthorizationImplementedError→ 500 for any authenticated, authorized, non-superuser reaching a detail route.The fault was masked in two ways, which is why it surfaced only in production as a recurring 500:
So only a plain member of the row's product — the common case — hit it.
Fix
Resolve the join row to its
product(LocationProductReference) orfinding(LocationFindingReference) before callingcheck_object_permission, mirroring the existing nativeLocation(Product|Finding)ReferencePermissionclasses. This hands the authorization layer an object it already knows how to authorize, so the same change fixes both the open-source and Pro authorization implementations with no change needed on the Pro side. No migration and no model change.Test results
Added
unittests/test_v3_endpoint_compat_api_authz.py, which drives both detail routes as an authorized non-superuser product member:NoAuthorizationImplementedError);Verified locally against Postgres on
dev. The new tests plus the existing endpoint/location authorization suites (test_v3_endpoint_route_authz,test_apiv2_endpoint_deprecation_contract,test_apiv2_endpoint,test_endpoint_status_cross_product_authz,test_location_finding_reference_authz,test_v3_location_reference_authz) all pass. Ruff clean.Documentation
No documentation change — this restores the documented behavior of existing routes; no new feature or setting.
Checklist
dev.devbranch.Generated by Claude Code