Adding logging related to CORS configuration

Removing unused `allow_placeholder_references` property that causes confusion with `auto_create_placeholder_references`
Improving `.dockerignore` so that it ignores specific target files/directories that are generated by MVN/java, but not the .war file (so that compiled .war files can be easily turned into a docker image)
This commit is contained in:
Sean McIlvenna
2021-05-27 14:07:05 -07:00
parent 9760e586b6
commit a150aeb4d2
5 changed files with 18 additions and 14 deletions

View File

@@ -1,3 +1,12 @@
target
target/classes/
target/failsafe-reports/
target/generated-*
target/maven-*
target/ROOT
target/test-classes/
target/war
target/duplicate-finder-result.xml
target/jacoco.exec
target/*.original
.idea
.git

View File

@@ -28,7 +28,6 @@ public class AppProperties {
private Boolean allow_external_references = false;
private Boolean allow_multiple_delete = false;
private Boolean allow_override_default_search_params = true;
private Boolean allow_placeholder_references = true;
private Boolean auto_create_placeholder_reference_targets = false;
private Boolean enable_index_missing_fields = false;
private Boolean enable_repository_validating_interceptor = false;
@@ -240,14 +239,6 @@ public class AppProperties {
this.allow_override_default_search_params = allow_override_default_search_params;
}
public Boolean getAllow_placeholder_references() {
return allow_placeholder_references;
}
public void setAllow_placeholder_references(Boolean allow_placeholder_references) {
this.allow_placeholder_references = allow_placeholder_references;
}
public Boolean getAuto_create_placeholder_reference_targets() {
return auto_create_placeholder_reference_targets;
}

View File

@@ -48,6 +48,7 @@ import java.util.*;
import java.util.stream.Collectors;
public class BaseJpaRestfulServer extends RestfulServer {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseJpaRestfulServer.class);
@Autowired
DaoRegistry daoRegistry;
@@ -270,6 +271,7 @@ public class BaseJpaRestfulServer extends RestfulServer {
// showing a typical setup. You should customize this
// to your specific needs
if (appProperties.getCors() != null) {
ourLog.info("CORS is enabled on this server");
CorsConfiguration config = new CorsConfiguration();
config.addAllowedHeader(HttpHeaders.ORIGIN);
config.addAllowedHeader(HttpHeaders.ACCEPT);
@@ -279,9 +281,10 @@ public class BaseJpaRestfulServer extends RestfulServer {
config.addAllowedHeader("x-fhir-starter");
config.addAllowedHeader("X-Requested-With");
config.addAllowedHeader("Prefer");
List<String> allAllowedCORSOrigins = appProperties.getCors().getAllowed_origin();
allAllowedCORSOrigins.forEach(config::addAllowedOriginPattern);
ourLog.info("CORS allows the following origins: " + String.join(", ", allAllowedCORSOrigins));
config.addExposedHeader("Location");
config.addExposedHeader("Content-Location");
@@ -292,7 +295,9 @@ public class BaseJpaRestfulServer extends RestfulServer {
// Create the interceptor and register it
CorsInterceptor interceptor = new CorsInterceptor(config);
registerInterceptor(interceptor);
}
} else {
ourLog.info("CORS is disabled on this server");
}
// If subscriptions are enabled, we want to register the interceptor that
// will activate them and match results against them

View File

@@ -37,8 +37,8 @@ public class FhirServerConfigCommon {
ourLog.info("Server configured to " + (appProperties.getAllow_multiple_delete() ? "allow" : "deny") + " multiple deletes");
ourLog.info("Server configured to " + (appProperties.getAllow_external_references() ? "allow" : "deny") + " external references");
ourLog.info("Server configured to " + (appProperties.getExpunge_enabled() ? "enable" : "disable") + " expunges");
ourLog.info("Server configured to " + (appProperties.getAllow_placeholder_references() ? "allow" : "deny") + " placeholder references");
ourLog.info("Server configured to " + (appProperties.getAllow_override_default_search_params() ? "allow" : "deny") + " overriding default search params");
ourLog.info("Server configured to " + (appProperties.getAuto_create_placeholder_reference_targets() ? "allow" : "disable") + " auto-creating placeholder references");
if (appProperties.getSubscription().getEmail() != null) {
AppProperties.Subscription.Email email = appProperties.getSubscription().getEmail();

View File

@@ -58,7 +58,6 @@ hapi:
# allow_external_references: true
# allow_multiple_delete: true
# allow_override_default_search_params: true
# allow_placeholder_references: true
# auto_create_placeholder_reference_targets: false
# cql_enabled: true
# default_encoding: JSON