Merge branch 'graal-vm-conditional-adaptation' into 'main'
GraalVM for cors See merge request fforesight/swagger-commons!1
This commit is contained in:
commit
c88c7851f9
2
.gitignore
vendored
2
.gitignore
vendored
@ -31,3 +31,5 @@ build/
|
|||||||
|
|
||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.DS_Store/
|
||||||
|
.DS_Store
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.knecon.fforesight.swaggercommons;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class CorsConfigurer implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
private final boolean corsEnabled;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public CorsConfigurer(@Value("${cors.enabled:false}") boolean corsEnabled) {
|
||||||
|
|
||||||
|
this.corsEnabled = corsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
|
||||||
|
if (corsEnabled) {
|
||||||
|
log.info("Cross Origin Requests are enabled !!!");
|
||||||
|
registry.addMapping("/**").allowedOrigins("*").allowedMethods("GET", "POST", "DELETE", "PUT", "HEAD");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -40,6 +40,7 @@ import io.swagger.v3.oas.models.security.OAuthFlow;
|
|||||||
import io.swagger.v3.oas.models.security.OAuthFlows;
|
import io.swagger.v3.oas.models.security.OAuthFlows;
|
||||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||||
|
import lombok.Value;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -87,23 +88,6 @@ public class SpringDocConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnProperty(value = "cors.enabled", havingValue = "true")
|
|
||||||
public WebMvcConfigurer corsConfigurer() {
|
|
||||||
|
|
||||||
return new WebMvcConfigurer() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
|
||||||
|
|
||||||
log.info("Cross Origin Requests are enabled !!!");
|
|
||||||
registry.addMapping("/**").allowedOrigins("*").allowedMethods("GET", "POST", "DELETE", "PUT", "HEAD");
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CorsConfigurationSource corsConfigurationSource() {
|
public CorsConfigurationSource corsConfigurationSource() {
|
||||||
|
|
||||||
@ -143,8 +127,8 @@ public class SpringDocConfiguration {
|
|||||||
|
|
||||||
private OAuthFlow createAuthorizationCodeFlow(SpringDocProperties springDocProperties) {
|
private OAuthFlow createAuthorizationCodeFlow(SpringDocProperties springDocProperties) {
|
||||||
|
|
||||||
return new OAuthFlow().authorizationUrl(springDocProperties.getAuthServerUrl()+PROTOCOL_URL_FORMAT + "/auth")
|
return new OAuthFlow().authorizationUrl(springDocProperties.getAuthServerUrl() + PROTOCOL_URL_FORMAT + "/auth")
|
||||||
.tokenUrl(springDocProperties.getAuthServerUrl()+PROTOCOL_URL_FORMAT + "/token");
|
.tokenUrl(springDocProperties.getAuthServerUrl() + PROTOCOL_URL_FORMAT + "/token");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user