mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-16 07:10:48 +00:00
Bug 4943: Implemented authentication via secret for API
/api/v1/leaderboards/{name}/marks/{id}/gps_fixes
This commit is contained in:
1 parent
0e5d4538d9
commit
b5fa47d455
3 files changed
+11
-8
No files matched your search
+2
-2
@@ -73,7 +73,7 @@ public class LeaderboardsResourcePingMarkTest extends AbstractJaxRsApiTest {
|
||||
public void testCheckinAndCheckout() throws Exception {
|
||||
{
|
||||
Response response = leaderboardsResource.pingMark(PING_MARK_JSON, leaderboard.getName(),
|
||||
mark.getId().toString());
|
||||
mark.getId().toString(), null);
|
||||
assertThat("response is ok", response.getStatus(), equalTo(Response.Status.OK.getStatusCode()));
|
||||
Map<Mark, List<DeviceMappingWithRegattaLogEvent<Mark>>> mappings = new RegattaLogDeviceMarkMappingFinder(
|
||||
log).analyze();
|
||||
@@ -85,7 +85,7 @@ public class LeaderboardsResourcePingMarkTest extends AbstractJaxRsApiTest {
|
||||
// now produce a second ping; this should produce also only one fix; no additional artificial fixes are
|
||||
// created (anymore; they used to be before bug2851)
|
||||
Response response = leaderboardsResource.pingMark(PING2_MARK_JSON, leaderboard.getName(),
|
||||
mark.getId().toString());
|
||||
mark.getId().toString(), null);
|
||||
assertThat("response is ok", response.getStatus(), equalTo(Response.Status.OK.getStatusCode()));
|
||||
Map<Mark, List<DeviceMappingWithRegattaLogEvent<Mark>>> mappings = new RegattaLogDeviceMarkMappingFinder(
|
||||
log).analyze();
|
||||
|
||||
+8
-5
@@ -1247,10 +1247,6 @@ public class LeaderboardsResource extends AbstractLeaderboardsResource {
|
||||
.entity("Leaderboard with name '" + leaderboardName + "'does not contain a RegattaLog'.")
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
boolean skip = skipChecksDueToCorrectSecret(leaderboardName, secret);
|
||||
if (!skip) {
|
||||
getSecurityService().checkCurrentUserReadPermission(leaderboard);
|
||||
}
|
||||
Mark mark = null;
|
||||
for (final RaceColumn raceColumn : leaderboard.getRaceColumns()) {
|
||||
for (final Mark availableMark : raceColumn.getAvailableMarks()) {
|
||||
@@ -1264,6 +1260,10 @@ public class LeaderboardsResource extends AbstractLeaderboardsResource {
|
||||
return Response.status(Status.NOT_FOUND).entity("Could not find a mark with ID '" + StringEscapeUtils.escapeHtml(markId) + "'.")
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
boolean skip = skipChecksDueToCorrectSecret(leaderboardName, secret);
|
||||
if (!skip) {
|
||||
getSecurityService().checkCurrentUserReadPermission(leaderboard);
|
||||
}
|
||||
final TimePoint now = MillisecondsTimePoint.now();
|
||||
Position lastKnownPosition = getService().getMarkPosition(mark, (LeaderboardThatHasRegattaLike) leaderboard, now);
|
||||
final JSONObject result = markWithPositionSerializer.serialize(new Pair<>(mark, lastKnownPosition));
|
||||
@@ -1290,7 +1290,7 @@ public class LeaderboardsResource extends AbstractLeaderboardsResource {
|
||||
@Path("{leaderboardName}/marks/{markId}/gps_fixes")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Response pingMark(String json, @PathParam("leaderboardName") String leaderboardName,
|
||||
@PathParam("markId") String markId) throws HTTPException {
|
||||
@PathParam("markId") String markId, @QueryParam("secret") String regattaSecret) throws HTTPException {
|
||||
logger.fine("Post issued to " + this.getClass().getName());
|
||||
final RacingEventService service = getService();
|
||||
Leaderboard leaderboard = getService().getLeaderboardByName(leaderboardName);
|
||||
@@ -1313,6 +1313,9 @@ public class LeaderboardsResource extends AbstractLeaderboardsResource {
|
||||
return Response.status(Status.NOT_FOUND).entity("Could not find a mark with ID '" + StringEscapeUtils.escapeHtml(markId) + "'.")
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
if (!skipChecksDueToCorrectSecret(leaderboardName, regattaSecret)) {
|
||||
getSecurityService().checkCurrentUserUpdatePermission(leaderboard);
|
||||
}
|
||||
// grab the position as found in TrackedRaces attached to the leaderboard
|
||||
final GPSFix fix;
|
||||
try {
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ This is done by adding the fixes to the GPSFixStore, and creating device-mapping
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Optional parameters:</td>
|
||||
<td>None</td>
|
||||
<td>secret: in case the given secret is equal to the one stored in the regatta defined by {name}, further security checks will be skipped.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Request method:</td>
|
||||
|
||||
Reference in new issue
Block a user