Skip to content

Commit 6ab3faa

Browse files
fix: Add more security to the pilot creation router
1 parent 8de3991 commit 6ab3faa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

diracx-routers/src/diracx/routers/pilots/management.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
PilotFieldsMapping,
1313
PilotStatus,
1414
)
15-
from diracx.core.properties import GENERIC_PILOT
15+
from diracx.core.properties import GENERIC_PILOT, JOB_ADMINISTRATOR
1616
from diracx.logic.pilots.management import (
1717
delete_pilots as delete_pilots_bl,
1818
)
@@ -72,10 +72,17 @@ async def add_pilot_stamps(
7272
if GENERIC_PILOT in user_info.properties:
7373
if len(pilot_stamps) != 1:
7474
raise HTTPException(
75-
status_code=status.HTTP_401_UNAUTHORIZED,
75+
status_code=status.HTTP_403_FORBIDDEN,
7676
detail="As a pilot, you can only create yourself.",
7777
)
7878

79+
if JOB_ADMINISTRATOR not in user_info.properties:
80+
if not vo == user_info.vo:
81+
raise HTTPException(
82+
status_code=status.HTTP_403_FORBIDDEN,
83+
detail="You can create pilots only for your VO.",
84+
)
85+
7986
try:
8087
await register_new_pilots(
8188
pilot_db=pilot_db,

0 commit comments

Comments
 (0)