Skip to content

Commit a79ceff

Browse files
eastandwestwindpattisdr
authored andcommitted
PROD-2254: User must have delete scope to delete systems (#5037)
Co-authored-by: Dawn Pattison <pattisdr@users.noreply.github.com>
1 parent c62b1f1 commit a79ceff

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The types of changes are:
2323
### Fixed
2424
- Fixed a bug where system information form was not loading for Viewer users [#5034](https://github.com/ethyca/fides/pull/5034)
2525
- Fixed viewers being given the option to delete systems [#5035](https://github.com/ethyca/fides/pull/5035)
26+
- Restrict Delete Systems API endpoint such that user must have "SYSTEM_DELETE" scope [#5037](https://github.com/ethyca/fides/pull/5037)
2627

2728
### Removed
2829
- Removed the `fetch` polyfill from FidesJS [#5026](https://github.com/ethyca/fides/pull/5026)

src/fides/api/api/v1/endpoints/system.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@
3333
from fides.api.models.sql_models import System # type:ignore[attr-defined]
3434
from fides.api.oauth.system_manager_oauth_util import (
3535
verify_oauth_client_for_system_from_fides_key,
36-
verify_oauth_client_for_system_from_fides_key_cli,
3736
verify_oauth_client_for_system_from_request_body_cli,
3837
)
39-
from fides.api.oauth.utils import get_current_user, verify_oauth_client_prod
38+
from fides.api.oauth.utils import (
39+
get_current_user,
40+
verify_oauth_client_prod,
41+
)
4042
from fides.api.schemas.connection_configuration import connection_secrets_schemas
4143
from fides.api.schemas.connection_configuration.connection_config import (
4244
BulkPutConnectionConfiguration,
@@ -294,6 +296,12 @@ async def upsert(
294296

295297
@SYSTEM_ROUTER.delete(
296298
"/{fides_key}",
299+
dependencies=[
300+
Security(
301+
verify_oauth_client_prod,
302+
scopes=[SYSTEM_DELETE],
303+
)
304+
],
297305
responses={
298306
status.HTTP_403_FORBIDDEN: {
299307
"content": {
@@ -311,10 +319,7 @@ async def upsert(
311319
},
312320
)
313321
async def delete(
314-
fides_key: str = Security(
315-
verify_oauth_client_for_system_from_fides_key_cli,
316-
scopes=[SYSTEM_DELETE],
317-
), # Security dependency defined here instead of the path operation decorator so we have access to the fides_key
322+
fides_key: str,
318323
# to retrieve the System and also return a value
319324
db: AsyncSession = Depends(get_async_db),
320325
) -> Dict:

tests/ctl/core/test_api.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,9 +2542,7 @@ def test_system_delete_as_system_manager(
25422542
resource_id=system.fides_key,
25432543
headers=auth_header,
25442544
)
2545-
assert result.status_code == HTTP_200_OK
2546-
assert result.json()["message"] == "resource deleted"
2547-
assert result.json()["resource"]["fides_key"] == system.fides_key
2545+
assert result.status_code == HTTP_403_FORBIDDEN
25482546

25492547
def test_delete_system_deletes_connection_config_and_dataset(
25502548
self,

tests/ops/service/connectors/test_queryconfig.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ def test_generate_query(
475475
"birthday": 1,
476476
"comments": 1,
477477
"customer_id": 1,
478+
"customer_uuid": 1,
478479
"emergency_contacts": 1,
479480
"children": 1,
480481
"gender": 1,

0 commit comments

Comments
 (0)