Skip to content

Commit

Permalink
Allow Slack API endpoints (#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
DementevNikita authored Nov 14, 2022
1 parent 5f00c0e commit 846c537
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@

@UtilityClass
public final class SecurityConstants {

public static final String[] WHITELIST_PATHS = {"/actuator/**", "/favicon.ico", "/ingestion/**", "/img/**"};
public static final String[] WHITELIST_PATHS =
{"/actuator/**", "/favicon.ico", "/ingestion/**", "/img/**", "/api/slack/events"};

public static final List<SecurityRule> SECURITY_RULES = List.of(
new SecurityRule(NO_CONTEXT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public SecurityWebFilterChain securityWebFilterChainLoginForm(
return http
.csrf().disable()
.authorizeExchange()
.pathMatchers("/actuator/health", "/favicon.ico", "/ingestion/entities").permitAll()
.pathMatchers("/actuator/health", "/favicon.ico", "/ingestion/entities", "/api/slack/events").permitAll()
.pathMatchers("/**").authenticated()
.and().formLogin().authenticationSuccessHandler(authHandler)
.and().logout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.opendatadiscovery.oddplatform.dto.alert.ExternalAlert;
import org.opendatadiscovery.oddplatform.service.AlertService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

Expand All @@ -18,7 +18,7 @@ public class AlertManagerController {
private final AlertService alertService;

// TODO: define OpenAPI spec based on alert provider contract
@RequestMapping("ingestion/alert/alertmanager")
@PostMapping(path = "ingestion/alert/alertmanager")
public Mono<ResponseEntity<Void>> alertManagerWebhook(@RequestBody final Mono<AlertManagerRequest> request) {
return request
.flatMap(req -> alertService.handleExternalAlerts(req.getAlerts()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import org.opendatadiscovery.oddplatform.datacollaboration.controller.parser.SlackEventParser;
import org.opendatadiscovery.oddplatform.datacollaboration.service.DataCollaborationService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

Expand All @@ -19,7 +19,7 @@ public class EventApiController {
private final DataCollaborationService dataCollaborationService;
private final SlackEventParser slackEventParser;

@RequestMapping("/api/slack/events")
@PostMapping(path = "/api/slack/events")
public Mono<ResponseEntity<SlackEventResponse>> handleSlackEvent(
@RequestBody final Mono<String> rawRequestBody
) {
Expand Down

0 comments on commit 846c537

Please sign in to comment.