Replace CrossOrigin annotaion with global configuration
This commit is contained in:
parent
1d1226dc5f
commit
85b37dd16d
|
@ -1,37 +1,43 @@
|
|||
package eu.eudat.configurations;
|
||||
|
||||
import eu.eudat.controllers.interceptors.RequestInterceptor;
|
||||
import eu.eudat.logic.handlers.PrincipalArgumentResolver;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EnableAsync
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class WebMVCConfiguration extends WebMvcConfigurerAdapter {
|
||||
public class WebMVCConfiguration implements WebMvcConfigurer {
|
||||
|
||||
private ApiContext apiContext;
|
||||
|
||||
private AuthenticationService verifiedUserAuthenticationService;
|
||||
private AuthenticationService nonVerifiedUserAuthenticationService;
|
||||
private final AuthenticationService verifiedUserAuthenticationService;
|
||||
private final AuthenticationService nonVerifiedUserAuthenticationService;
|
||||
|
||||
@Autowired
|
||||
public WebMVCConfiguration(ApiContext apiContext, AuthenticationService verifiedUserAuthenticationService, AuthenticationService nonVerifiedUserAuthenticationService) {
|
||||
private final Environment environment;
|
||||
|
||||
public WebMVCConfiguration(ApiContext apiContext, AuthenticationService verifiedUserAuthenticationService, AuthenticationService nonVerifiedUserAuthenticationService, Environment environment) {
|
||||
this.apiContext = apiContext;
|
||||
this.verifiedUserAuthenticationService = verifiedUserAuthenticationService;
|
||||
this.nonVerifiedUserAuthenticationService = nonVerifiedUserAuthenticationService;
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/api/**").allowedOrigins(this.environment.getProperty("dmp.domain"));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Override
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
argumentResolvers.add(new PrincipalArgumentResolver(verifiedUserAuthenticationService, nonVerifiedUserAuthenticationService));
|
||||
|
|
|
@ -38,7 +38,6 @@ import static eu.eudat.types.Authorities.ADMIN;
|
|||
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/admin/"})
|
||||
public class Admin extends BaseController {
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.util.List;
|
|||
* Created by ikalyvas on 3/28/2018.
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/common"})
|
||||
public class CommonController {
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.transaction.Transactional;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = "api/contactEmail")
|
||||
public class ContactEmail {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContactEmail.class);
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = "api/currency")
|
||||
public class CurrencyController {
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ import static eu.eudat.types.Authorities.ADMIN;
|
|||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/dmpprofile"})
|
||||
public class DMPProfileController extends BaseController {
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ import static org.springframework.http.MediaType.*;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/dmps/"})
|
||||
public class DMPs extends BaseController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DMPs.class);
|
||||
|
|
|
@ -22,11 +22,10 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api"})
|
||||
public class DashBoardController extends BaseController {
|
||||
|
||||
private DashBoardManager dashBoardManager;
|
||||
private final DashBoardManager dashBoardManager;
|
||||
@Autowired
|
||||
public DashBoardController(ApiContext apiContext, DashBoardManager dashBoardManager) {
|
||||
super(apiContext);
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.util.List;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/external/datarepos"})
|
||||
public class DataRepositories extends BaseController {
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.UUID;
|
|||
import static eu.eudat.types.Authorities.ADMIN;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api"})
|
||||
public class DatasetProfileController extends BaseController {
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api"})
|
||||
public class DatasetProfiles extends BaseController {
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ import static eu.eudat.types.Authorities.ANONYMOUS;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/datasets/"})
|
||||
public class Datasets extends BaseController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Datasets.class);
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.transaction.Transactional;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = "api/emailConfirmation")
|
||||
public class EmailConfirmation {
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.transaction.Transactional;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = "api/emailMergeConfirmation")
|
||||
public class EmailMergeConfirmation {
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.UUID;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api"})
|
||||
public class ExternalDatasets extends BaseController {
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ import java.util.UUID;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/file/"})
|
||||
public class FileController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FileController.class);
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/funders/"})
|
||||
public class Funders extends BaseController {
|
||||
private FunderManager funderManager;
|
||||
|
|
|
@ -28,7 +28,6 @@ import static eu.eudat.types.Authorities.ANONYMOUS;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/grants/"})
|
||||
public class Grants extends BaseController {
|
||||
private GrantManager grantManager;
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.util.List;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/external/journals"})
|
||||
public class JournalsController extends BaseController {
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import java.io.*;
|
|||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/language/"})
|
||||
public class LanguageController {
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/external/licenses"})
|
||||
public class Licenses extends BaseController {
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/lock/"})
|
||||
public class LockController {
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ import java.security.GeneralSecurityException;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = "api/auth")
|
||||
public class Login {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Login.class);
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.List;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api"})
|
||||
public class Organisations extends BaseController {
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api"})
|
||||
public class Prefillings {
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/projects/"})
|
||||
public class Projects extends BaseController {
|
||||
private ProjectManager projectManager;
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/external/pubrepos"})
|
||||
public class PubRepositoriesController extends BaseController {
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/external/publications"})
|
||||
public class PublicationsController extends BaseController {
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import javax.validation.Valid;
|
|||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/quick-wizard/"})
|
||||
public class QuickWizardController extends BaseController {
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.util.List;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api"})
|
||||
public class Registries extends BaseController {
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.util.Map;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/researchers"})
|
||||
|
||||
public class Researchers extends BaseController {
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.util.List;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api"})
|
||||
public class Services extends BaseController {
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.stream.Collectors;
|
|||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api"})
|
||||
public class TagController extends BaseController {
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/external/taxonomies"})
|
||||
public class TaxonomiesController extends BaseController {
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.stream.Stream;
|
|||
import static eu.eudat.types.Authorities.ADMIN;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/userguide/"})
|
||||
public class UserGuideController {
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.UUID;
|
|||
|
||||
@RequestMapping("api/invite/")
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class UserInvitationController extends BaseController {
|
||||
|
||||
private InvitationsManager invitationsManager;
|
||||
|
|
|
@ -31,7 +31,6 @@ import static eu.eudat.types.Authorities.ADMIN;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = "api/user")
|
||||
public class Users extends BaseController {
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.List;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api"})
|
||||
public class Validation extends BaseController {
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.net.*;
|
|||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class Proxy {
|
||||
|
||||
private String allowedHost;
|
||||
|
|
Loading…
Reference in New Issue