Skip to content

Commit

Permalink
fix: add CrossOrigin annotation to controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgxvii committed Apr 3, 2023
1 parent c15b662 commit 8d274e4
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(@NonNull CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE").allowedOrigins("*");
// NOTE: allowedHeaders("*") is causing CORS issues so this has been removed (empty allows all headers by default)
registry.addMapping("/**")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedOrigins("*")
.allowedHeaders("*");
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.radarbase.appserver.dto.fcm.FcmDataMessages;
import org.radarbase.appserver.service.FcmDataMessageService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -47,6 +48,7 @@
*
* @author yatharthranjan
*/
@CrossOrigin
@RestController
public class FcmDataMessageController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.radarbase.appserver.dto.fcm.FcmNotifications;
import org.radarbase.appserver.service.FcmNotificationService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -47,6 +48,7 @@
*
* @author yatharthranjan
*/
@CrossOrigin
@RestController
public class FcmNotificationController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -34,6 +35,7 @@
import java.io.IOException;
import java.net.MalformedURLException;

@CrossOrigin
@RestController
public class GithubEndpoint {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.radarbase.appserver.dto.NotificationStateEventDto;
import org.radarbase.appserver.service.NotificationStateEventService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -36,6 +37,7 @@
import radar.spring.auth.common.Authorized;
import radar.spring.auth.common.PermissionOn;

@CrossOrigin
@RestController
public class NotificationStateEventController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
import org.radarbase.appserver.config.AuthConfig.AuthEntities;
import org.radarbase.appserver.config.AuthConfig.AuthPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import radar.spring.auth.common.Authorized;
import radar.spring.auth.common.PermissionOn;

@CrossOrigin
@RestController
public class ProtocolEndpoint {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.Locale;
import java.util.Optional;

@CrossOrigin
@RestController
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class QuestionnaireScheduleEndpoint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.radarbase.auth.token.RadarToken;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -58,6 +59,7 @@
* @see <a href="https://github.com/RADAR-base/ManagementPortal">Management Portal</a>
* @author yatharthranjan
*/
@CrossOrigin
@RestController
@Slf4j
public class RadarProjectController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@
import org.radarbase.appserver.service.UserService;
import org.radarbase.auth.token.RadarToken;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import radar.spring.auth.common.AuthAspect;
import radar.spring.auth.common.Authorization;
import radar.spring.auth.common.Authorized;
Expand All @@ -51,6 +59,7 @@
* @see <a href="https://github.com/RADAR-base/ManagementPortal">Management Portal</a>
* @author yatharthranjan
*/
@CrossOrigin
@RestController
public class RadarUserController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@
import org.radarbase.appserver.dto.TaskStateEventDto;
import org.radarbase.appserver.service.TaskStateEventService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import radar.spring.auth.common.Authorized;
import radar.spring.auth.common.PermissionOn;

import javax.naming.SizeLimitExceededException;
import java.util.List;

@CrossOrigin
@RestController
public class TaskStateEventController {

Expand Down

0 comments on commit 8d274e4

Please sign in to comment.