Factored out web secrity modules, GEOS-5972. Backport of #357.