Add cors configuration support.
parent
a829844c1a
commit
3106b3e94a
|
@ -0,0 +1,24 @@
|
||||||
|
package com.wisemapping.config.rest;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebMvc
|
||||||
|
public class WebConfig implements WebMvcConfigurer {
|
||||||
|
@Value("${app.security.corsAllowedOrigins:}")
|
||||||
|
private String corsAllowedOrigins;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(@NotNull CorsRegistry registry) {
|
||||||
|
if (!corsAllowedOrigins.isEmpty()) {
|
||||||
|
registry.addMapping("/api/**")
|
||||||
|
.allowedOrigins(corsAllowedOrigins).
|
||||||
|
maxAge(3600);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,7 +40,6 @@ import java.util.List;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/restful/account")
|
@RequestMapping("/api/restful/account")
|
||||||
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
||||||
@CrossOrigin
|
|
||||||
public class AccountController extends BaseController {
|
public class AccountController extends BaseController {
|
||||||
@Qualifier("userService")
|
@Qualifier("userService")
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin
|
|
||||||
@RequestMapping("/api/restful")
|
@RequestMapping("/api/restful")
|
||||||
public class JwtAuthController {
|
public class JwtAuthController {
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/restful/maps")
|
@RequestMapping("/api/restful/maps")
|
||||||
@CrossOrigin
|
|
||||||
public class MindmapController extends BaseController {
|
public class MindmapController extends BaseController {
|
||||||
private final Logger logger = LogManager.getLogger();
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ app:
|
||||||
# Redirect to this url, this url must be configured in the google app {baseurl}/c/registration-google
|
# Redirect to this url, this url must be configured in the google app {baseurl}/c/registration-google
|
||||||
#security.oauth2.google.callbackUrl=<oauth callback url>
|
#security.oauth2.google.callbackUrl=<oauth callback url>
|
||||||
security:
|
security:
|
||||||
|
corsAllowedOrigins: https://dev.wisemapping.com
|
||||||
oauth2:
|
oauth2:
|
||||||
google:
|
google:
|
||||||
confirmUrl: https://oauth2.googleapis.com/token
|
confirmUrl: https://oauth2.googleapis.com/token
|
||||||
|
|
Loading…
Reference in New Issue