Bladeren bron

enforce admin-only for logs API

tags/v1.1.4
Jonathan Cobb 4 jaren geleden
bovenliggende
commit
141af88b96
1 gewijzigde bestanden met toevoegingen van 5 en 2 verwijderingen
  1. +5
    -2
      bubble-server/src/main/java/bubble/resources/cloud/NetworksResource.java

+ 5
- 2
bubble-server/src/main/java/bubble/resources/cloud/NetworksResource.java Bestand weergeven

@@ -217,16 +217,19 @@ public class NetworksResource extends AccountOwnedResource<BubbleNetwork, Bubble
return configuration.subResource(BackupsResource.class, account, network); return configuration.subResource(BackupsResource.class, account, network);
} }


@Path("/{id}" + EP_LOGS)
@Path("/{id}"+EP_LOGS)
@NonNull public LogsResource getLogs(@NonNull @Context final ContainerRequest ctx, @NonNull public LogsResource getLogs(@NonNull @Context final ContainerRequest ctx,
@NonNull @PathParam("id") String id) { @NonNull @PathParam("id") String id) {
// caller must be admin
final Account caller = userPrincipal(ctx);
if (!caller.admin()) throw forbiddenEx();

final var network = find(ctx, id); final var network = find(ctx, id);
if (network == null) throw notFoundEx(id); if (network == null) throw notFoundEx(id);


// only available for this (current) network // only available for this (current) network
if (!configuration.getThisNetwork().getUuid().equals(network.getUuid())) throw forbiddenEx(); if (!configuration.getThisNetwork().getUuid().equals(network.getUuid())) throw forbiddenEx();


final Account caller = userPrincipal(ctx);
return configuration.subResource(LogsResource.class, caller); return configuration.subResource(LogsResource.class, caller);
} }
} }

Laden…
Annuleren
Opslaan