mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-26 17:34:41 +00:00
Adds missing permissions on alerts (#20387)
This commit is contained in:
parent
71927cc30b
commit
07cedb9d65
@ -78,7 +78,6 @@ import org.openmetadata.service.apps.bundles.changeEvent.AlertFactory;
|
|||||||
import org.openmetadata.service.apps.bundles.changeEvent.Destination;
|
import org.openmetadata.service.apps.bundles.changeEvent.Destination;
|
||||||
import org.openmetadata.service.events.errors.EventPublisherException;
|
import org.openmetadata.service.events.errors.EventPublisherException;
|
||||||
import org.openmetadata.service.events.scheduled.EventSubscriptionScheduler;
|
import org.openmetadata.service.events.scheduled.EventSubscriptionScheduler;
|
||||||
import org.openmetadata.service.events.subscription.AlertUtil;
|
|
||||||
import org.openmetadata.service.events.subscription.EventsSubscriptionRegistry;
|
import org.openmetadata.service.events.subscription.EventsSubscriptionRegistry;
|
||||||
import org.openmetadata.service.exception.EntityNotFoundException;
|
import org.openmetadata.service.exception.EntityNotFoundException;
|
||||||
import org.openmetadata.service.jdbi3.CollectionDAO;
|
import org.openmetadata.service.jdbi3.CollectionDAO;
|
||||||
@ -479,6 +478,8 @@ public class EventSubscriptionResource
|
|||||||
@PathParam("id")
|
@PathParam("id")
|
||||||
UUID id)
|
UUID id)
|
||||||
throws SchedulerException {
|
throws SchedulerException {
|
||||||
|
OperationContext operationContext = new OperationContext(entityType, MetadataOperation.DELETE);
|
||||||
|
authorizer.authorize(securityContext, operationContext, getResourceContextById(id));
|
||||||
EventSubscription eventSubscription = repository.get(null, id, repository.getFields("id"));
|
EventSubscription eventSubscription = repository.get(null, id, repository.getFields("id"));
|
||||||
EventSubscriptionScheduler.getInstance().deleteEventSubscriptionPublisher(eventSubscription);
|
EventSubscriptionScheduler.getInstance().deleteEventSubscriptionPublisher(eventSubscription);
|
||||||
EventSubscriptionScheduler.getInstance().deleteSuccessfulAndFailedEventsRecordByAlert(id);
|
EventSubscriptionScheduler.getInstance().deleteSuccessfulAndFailedEventsRecordByAlert(id);
|
||||||
@ -509,6 +510,8 @@ public class EventSubscriptionResource
|
|||||||
@PathParam("id")
|
@PathParam("id")
|
||||||
UUID id)
|
UUID id)
|
||||||
throws SchedulerException {
|
throws SchedulerException {
|
||||||
|
OperationContext operationContext = new OperationContext(entityType, MetadataOperation.DELETE);
|
||||||
|
authorizer.authorize(securityContext, operationContext, getResourceContextById(id));
|
||||||
EventSubscription eventSubscription = repository.get(null, id, repository.getFields("id"));
|
EventSubscription eventSubscription = repository.get(null, id, repository.getFields("id"));
|
||||||
EventSubscriptionScheduler.getInstance().deleteEventSubscriptionPublisher(eventSubscription);
|
EventSubscriptionScheduler.getInstance().deleteEventSubscriptionPublisher(eventSubscription);
|
||||||
EventSubscriptionScheduler.getInstance().deleteSuccessfulAndFailedEventsRecordByAlert(id);
|
EventSubscriptionScheduler.getInstance().deleteSuccessfulAndFailedEventsRecordByAlert(id);
|
||||||
@ -532,6 +535,8 @@ public class EventSubscriptionResource
|
|||||||
@PathParam("name")
|
@PathParam("name")
|
||||||
String name)
|
String name)
|
||||||
throws SchedulerException {
|
throws SchedulerException {
|
||||||
|
OperationContext operationContext = new OperationContext(entityType, MetadataOperation.DELETE);
|
||||||
|
authorizer.authorize(securityContext, operationContext, getResourceContextByName(name));
|
||||||
EventSubscription eventSubscription =
|
EventSubscription eventSubscription =
|
||||||
repository.getByName(null, name, repository.getFields("id"));
|
repository.getByName(null, name, repository.getFields("id"));
|
||||||
EventSubscriptionScheduler.getInstance().deleteEventSubscriptionPublisher(eventSubscription);
|
EventSubscriptionScheduler.getInstance().deleteEventSubscriptionPublisher(eventSubscription);
|
||||||
@ -621,7 +626,9 @@ public class EventSubscriptionResource
|
|||||||
@Parameter(description = "AlertType", schema = @Schema(type = "string"))
|
@Parameter(description = "AlertType", schema = @Schema(type = "string"))
|
||||||
@PathParam("alertType")
|
@PathParam("alertType")
|
||||||
CreateEventSubscription.AlertType alertType) {
|
CreateEventSubscription.AlertType alertType) {
|
||||||
|
OperationContext operationContext =
|
||||||
|
new OperationContext(entityType, MetadataOperation.VIEW_ALL);
|
||||||
|
authorizer.authorize(securityContext, operationContext, getResourceContext());
|
||||||
if (alertType.equals(NOTIFICATION)) {
|
if (alertType.equals(NOTIFICATION)) {
|
||||||
return new ResultList<>(EventsSubscriptionRegistry.listEntityNotificationDescriptors());
|
return new ResultList<>(EventsSubscriptionRegistry.listEntityNotificationDescriptors());
|
||||||
} else {
|
} else {
|
||||||
@ -629,26 +636,6 @@ public class EventSubscriptionResource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/validation/condition/{expression}")
|
|
||||||
@Operation(
|
|
||||||
operationId = "validateCondition",
|
|
||||||
summary = "Validate a given condition",
|
|
||||||
description = "Validate a given condition expression used in filtering rules.",
|
|
||||||
responses = {
|
|
||||||
@ApiResponse(responseCode = "204", description = "No value is returned"),
|
|
||||||
@ApiResponse(responseCode = "400", description = "Invalid expression")
|
|
||||||
})
|
|
||||||
public void validateCondition(
|
|
||||||
@Context UriInfo uriInfo,
|
|
||||||
@Context SecurityContext securityContext,
|
|
||||||
@Parameter(description = "Expression to validate", schema = @Schema(type = "string"))
|
|
||||||
@PathParam("expression")
|
|
||||||
String expression) {
|
|
||||||
authorizer.authorizeAdmin(securityContext);
|
|
||||||
AlertUtil.validateExpression(expression, Boolean.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/{id}/processedEvents")
|
@Path("/{id}/processedEvents")
|
||||||
@Operation(
|
@Operation(
|
||||||
@ -671,6 +658,9 @@ public class EventSubscriptionResource
|
|||||||
@Parameter(description = "Id of the Event Subscription", schema = @Schema(type = "UUID"))
|
@Parameter(description = "Id of the Event Subscription", schema = @Schema(type = "UUID"))
|
||||||
@PathParam("id")
|
@PathParam("id")
|
||||||
UUID id) {
|
UUID id) {
|
||||||
|
OperationContext operationContext =
|
||||||
|
new OperationContext(entityType, MetadataOperation.VIEW_ALL);
|
||||||
|
authorizer.authorize(securityContext, operationContext, getResourceContextById(id));
|
||||||
return Response.ok()
|
return Response.ok()
|
||||||
.entity(EventSubscriptionScheduler.getInstance().checkIfPublisherPublishedAllEvents(id))
|
.entity(EventSubscriptionScheduler.getInstance().checkIfPublisherPublishedAllEvents(id))
|
||||||
.build();
|
.build();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user