Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions server/configs/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ management.server.port=@@shutdownPort@@
#useLocalBuild# font-src 'self' data: ${FONT.SOURCES} ; /* Limit font source loading locations */\
#useLocalBuild# script-src 'unsafe-eval' 'strict-dynamic' 'nonce-${REQUEST.SCRIPT.NONCE}' ; /* Limit scripts to those with nonces or transitive scripts */\
#useLocalBuild# base-uri 'self' ; /* Limit the base tags to only source from current server */\
#useLocalBuild# ${UPGRADE.INSECURE.REQUESTS} /* Conditionally add upgrade-secure-requests directive if HTTPS is required */\
#useLocalBuild# frame-ancestors 'self' ; /* Limit iframe content destinations (who can load this server's content into an iframe) */\
#useLocalBuild# frame-src 'self' ${FRAME.SOURCES} ; /* Limit iframe content sources (from what servers can this server's iframe content be loaded) */\
#useLocalBuild# report-uri /admin-contentSecurityPolicyReport.api?cspVersion=e11&${CSP.REPORT.PARAMS} ; /* Report any encountered CSP violations to the supplied URL */
#useLocalBuild# report-uri /admin-contentSecurityPolicyReport.api?cspVersion=e12&${CSP.REPORT.PARAMS} ; /* Report any encountered CSP violations to the local server */
## END OF CSP ENFORCE BLOCK (DO NOT CHANGE THIS TEXT)

## START OF CSP REPORT BLOCK (DO NOT CHANGE THIS TEXT)
Expand All @@ -149,7 +150,7 @@ csp.report=\
base-uri 'self' ; /* Limit the base tags to only source from current server */\
frame-ancestors 'self' ; /* Limit iframe content destinations (who can load this server's content into an iframe) */\
frame-src 'self' ${FRAME.SOURCES} ; /* Limit iframe content sources (from what servers can this server's iframe content be loaded) */\
report-uri /admin-contentSecurityPolicyReport.api?cspVersion=r11&${CSP.REPORT.PARAMS} ; /* Report any encountered CSP violations to the supplied URL */
report-uri /admin-contentSecurityPolicyReport.api?cspVersion=r12&${CSP.REPORT.PARAMS} ; /* Report any encountered CSP violations to the local server */
## END OF CSP REPORT BLOCK (DO NOT CHANGE THIS TEXT)

## Use a custom logging configuration
Expand Down
30 changes: 16 additions & 14 deletions server/embedded/src/org/labkey/embedded/LabKeyServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ public static void main(String[] args)

SpringApplication application = new SpringApplication(LabKeyServer.class);
application.addListeners(new ApplicationPidFileWriter("./labkey.pid"));
// A strong Content Security Policy that reports violations to this server
String strongCsp = """
default-src 'self' ;
connect-src 'self' ${CONNECTION.SOURCES} ;
object-src 'none' ;
style-src 'self' 'unsafe-inline' ${STYLE.SOURCES} ;
img-src 'self' data: ${IMAGE.SOURCES} ;
font-src 'self' data: ${FONT.SOURCES} ;
script-src 'unsafe-eval' 'strict-dynamic' 'nonce-${REQUEST.SCRIPT.NONCE}' ;
base-uri 'self' ;
${UPGRADE.INSECURE.REQUESTS}
frame-ancestors 'self' ;
frame-src 'self' ${FRAME.SOURCES} ;
report-uri /admin-contentSecurityPolicyReport.api?cspVersion=r12&${CSP.REPORT.PARAMS}
""";
application.setDefaultProperties(Map.of(
"server.tomcat.basedir", ".",
"server.tomcat.accesslog.directory", logHome,
Expand All @@ -81,20 +96,7 @@ public static void main(String[] args)
"server.error.include-stacktrace", "never",
"server.error.include-message", "always",

// A strong report-only Content Security Policy that reports violations to this server
"csp.report", """
default-src 'self' ;
connect-src 'self' ${CONNECTION.SOURCES} ;
object-src 'none' ;
style-src 'self' 'unsafe-inline' ${STYLE.SOURCES} ;
img-src 'self' data: ${IMAGE.SOURCES} ;
font-src 'self' data: ${FONT.SOURCES} ;
script-src 'unsafe-eval' 'strict-dynamic' 'nonce-${REQUEST.SCRIPT.NONCE}' ;
base-uri 'self' ;
frame-ancestors 'self' ;
frame-src 'self' ${FRAME.SOURCES} ;
report-uri /admin-contentSecurityPolicyReport.api?cspVersion=r11&${CSP.REPORT.PARAMS}
"""
"csp.report", strongCsp
));
application.setBannerMode(Banner.Mode.OFF);
application.run(args);
Expand Down