Skip to content

Commit

Permalink
require event_id parameter on personnel API calls
Browse files Browse the repository at this point in the history
The motivation is really just to lock down this endpoint. The only Rangers who need it are those with readIncident or writeIncident permissions. That's already a small subset of Rangers, even during event week. For the rest of the year, when almost no one has access to read or write incidents, the privacy benefit here becomes better still.
  • Loading branch information
srabraham committed Nov 3, 2024
1 parent d99c05f commit 10df62e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ims/application/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,9 @@ async def personnelResource(
"""
Personnel endpoint.
"""
eventId = queryValue(request, "event_id")

Check warning on line 228 in src/ims/application/_api.py

View check run for this annotation

Codecov / codecov/patch

src/ims/application/_api.py#L228

Added line #L228 was not covered by tests
await self.config.authProvider.authorizeRequest(
request, None, Authorization.readPersonnel
request, eventId, Authorization.readPersonnel
)

stream, etag = await self.personnelData()
Expand Down
4 changes: 2 additions & 2 deletions src/ims/auth/_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,6 @@ async def authorizationsForUser(
authorizations = Authorization.none

if user is not None:
authorizations |= Authorization.readPersonnel

for shortName in user.shortNames:
if shortName in self.adminUsers:
authorizations |= Authorization.imsAdmin
Expand All @@ -410,12 +408,14 @@ async def authorizationsForUser(
authorizations |= Authorization.writeIncidents
authorizations |= Authorization.readIncidents
authorizations |= Authorization.writeIncidentReports
authorizations |= Authorization.readPersonnel

Check warning on line 411 in src/ims/auth/_provider.py

View check run for this annotation

Codecov / codecov/patch

src/ims/auth/_provider.py#L411

Added line #L411 was not covered by tests

else:
if self._matchACL(
user, frozenset(await self.store.readers(eventID))
):
authorizations |= Authorization.readIncidents
authorizations |= Authorization.readPersonnel

Check warning on line 418 in src/ims/auth/_provider.py

View check run for this annotation

Codecov / codecov/patch

src/ims/auth/_provider.py#L418

Added line #L418 was not covered by tests

if self._matchACL(
user,
Expand Down
2 changes: 1 addition & 1 deletion src/ims/element/static/incident.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function loadPersonnel(success) {
setErrorMessage(message);
}

jsonRequest(url_personnel, null, ok, fail);
jsonRequest(urlReplace(url_personnel + "?event_id=<event_id>"), null, ok, fail);
}


Expand Down

0 comments on commit 10df62e

Please sign in to comment.