Secure Web Files
Introduction
Goal
Configure which web files are publicly accessible.
Background
Web files are static resources used by the web application. Some must be publicly accessible so the browser client can use them to render a web page, e.g. CSS and Javascript files. Others, such as Freemarker templates, are only used server-side and should be secured from public access. Which web files are publicly accessible is configured through an allowlist.
Allowing Public Access to Web Files
Which web files should be publicly (HTTP/HTTPS) accessible is configured through an allowlist. This is a file called hst-allowlist.txt in v15.x and hst-whitelist.txt in v14.x.
The allowlist file is located in the bundle's root directory. When the bundle's root directory is site, the allowlist is located in the project at
/repository-data: /webfiles: /src: /main: /resources: /site: /hst-allowlist.txt:
* When using v14.x, replace hst-allowlist.txt with hst-whitelist.txt.
Projects created using the Maven archetype contain a default allowlist that grants public access to the folders css/, fonts/ and js/. The default contents of the allowlist are:
########################################################################## # # # This file must contain all files and folders that # # must be publicly available over http. Typically folders # # that contain server side scripts, such a freemarker # # templates, should not be added as they in general should # # not be publicly available. # # # # The allowlisting is *relative* to the 'web file bundle root' # # which is the folder in which this hst-allowlist.txt file is # # located. # # # # Examples assuming the web file bundle root is 'site': # # # # css/ : allowlists all descendant web files below 'site/css/' # # common.js : allowlists the file 'site/common.js' # # # # Note that the allowlisting is 'starts-with' based, thus for # # example allowlisting 'css' without '/' behind it, allowlists all # # files and folders that start with 'css' # # # ########################################################################## css/ fonts/ js/