Fix/rbac create sibling hardening#121
Conversation
|
Hi @bhudevbhanpuriya, this looks incomplete to me. The new DENIED_CREATOR_ROLES check has been added here, but the same endpoint-level authorization gap may still exist for other creator endpoints/entities as well, such as Thing, Observation, etc. If this PR is meant to fix the broader access control issue, those paths should probably be updated too. |
|
hi @ClaudioPrimerano, thanks for the thorough review! you're absolutely right , Thing, Observation , and any other creator endpoints with the same pattern should receive the same hardening. This PR was intentionally scoped as an incremental step (stacked on top of #120) to keep each change reviewable in isolation, but I should have been clearer that it doesn't claim to be a complete fix. |
5ae37c9 to
23b4ce1
Compare
|
i’ve addressed this in the latest push (commit 23b4ce1). also added: all create paths now enforce role checks before entering write transactions. this PR was initially scoped as an incremental step, but i’ve now expanded it to cover all create endpoints. let me know if anything still needs adjustment. |
… hardening
- Add DENIED_CREATOR_ROLES = {'viewer'} in rbac_roles.py
- Add check_create_permission() helper function
- Add early RBAC check to all create endpoints before write transaction
- Add bulk_observation and data_array_observation RBAC checks
- Add unit tests for check_create_permission
This addresses reviewer comments about incomplete endpoint coverage:
- Thing, Observation, Datastream, Location, etc all now protected
- All POST /Sensors, /Things, /Observations, /Datastreams covered
- Regression tests added for deny and allow scenarios
23b4ce1 to
ed7be22
Compare
Summary
This PR is a follow-up to the sensor-create RBAC hardening work and extends the same authorization pattern to sibling create endpoints for consistency.
It ensures that all related create routes enforce explicit RBAC checks at the API layer before entering write flows.
Previous Work
This change builds on the prior PR:
fix/rbac-sensor-create-hardening)Why This Follow-up
The previous PR fixed the primary access control gap for sensor creation.
However, similar create endpoints could still allow inconsistent behavior if not explicitly protected.
This PR applies the same deny-first RBAC model across sibling endpoints to prevent bypass via alternate write paths.
What this do Actually
sequenceDiagram title Follow-up RBAC Hardening Across Create Endpoints participant U as User (Viewer) participant Sensor as Sensor Endpoint (Fixed in previous PR) participant Others as Other Create Endpoints (Datastream / FoI / etc.) participant RBAC as RBAC Check participant DB as Database U->>Sensor: POST /Sensors Sensor->>RBAC: Check CREATE_SENSOR RBAC-->>Sensor: Denied Sensor-->>U: 403 Forbidden ✅ Note over Others: Before this PR\nNo consistent RBAC enforcement U->>Others: POST /Datastream / FoI / etc. Others->>DB: Insert Entity Others-->>U: 201 Created ❌ Note over Others: After this PR\nSame RBAC pattern applied U->>Others: POST /Datastream / FoI / etc. Others->>RBAC: Check CREATE permission RBAC-->>Others: Denied Others-->>U: 403 Forbidden ✅Changes
Updated Endpoints
datastream.pyobserved_property.pyfeature_of_interest.pysensor.pyNew Tests
test_create_sibling_rbac.pySecurity Impact
Testing
pytestCompatibility
Reviewer Notes
This PR is intentionally scoped as a stacked follow-up to the sensor-create RBAC fix to:
Solves #119 with improvisation