Skip to content

Commit 8fe08aa

Browse files
committed
allow shared secret when determining org for quotas update endpoint
try using `org_dep` directly in quotas endpoint this should be safe, since there's still a check for if user is superuser allow shared secret in org dep
1 parent 6db06b6 commit 8fe08aa

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

backend/btrixcloud/orgs.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,20 @@ async def org_dep(oid: UUID, user: User = Depends(user_dep)):
15231523

15241524
return org
15251525

1526+
async def org_or_shared_secret_dep(
1527+
oid: UUID, user: User = Depends(user_or_shared_secret_dep)
1528+
):
1529+
org = await ops.get_org_for_user_by_id(oid, user)
1530+
if not org:
1531+
raise HTTPException(status_code=404, detail="org_not_found")
1532+
if not org.is_viewer(user):
1533+
raise HTTPException(
1534+
status_code=403,
1535+
detail="User does not have permission to view this organization",
1536+
)
1537+
1538+
return org
1539+
15261540
async def org_crawl_dep(
15271541
org: Organization = Depends(org_dep), user: User = Depends(user_dep)
15281542
):
@@ -1653,7 +1667,7 @@ async def get_plans(user: User = Depends(user_dep)):
16531667
@router.post("/quotas", tags=["organizations"], response_model=UpdatedResponse)
16541668
async def update_quotas(
16551669
quotas: OrgQuotasIn,
1656-
org: Organization = Depends(org_owner_dep),
1670+
org: Organization = Depends(org_or_shared_secret_dep),
16571671
user: User = Depends(user_or_shared_secret_dep),
16581672
):
16591673
if not user.is_superuser:

backend/btrixcloud/subs.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,7 @@ async def add_sub_event(
245245
data["oid"] = oid
246246
await self.subs.insert_one(data)
247247

248-
def _get_sub_by_type_from_data(
249-
self, data: dict[str, object]
250-
) -> Union[
248+
def _get_sub_by_type_from_data(self, data: dict[str, object]) -> Union[
251249
SubscriptionCreateOut,
252250
SubscriptionImportOut,
253251
SubscriptionUpdateOut,

0 commit comments

Comments
 (0)