hsts - How to add strict-transport-security header to a Grails Application -


i have groovy code running on grails server. how configure hsts ? looked through groovy specs there nothing found useful.

this want achieve

when @ http response server. must see header such below

strict-transport-security: max-age=31536000 

can please suggest pointers ?

i suggest implement custom servlet filter, this:

@priority(integer.min_value) public class hstsfilter extends onceperrequestfilter {      public hstsfilter() {     }      @override     protected void dofilterinternal(httpservletrequest request, httpservletresponse response, filterchain filterchain) throws servletexception, ioexception {         filterchain.dofilter(request, response);         response.addheader("strict-transport-security", "max-age=31536000");     } } 

then need register in resources.groovy:

beans = {     hstsfilter(hstsfilter) } 

this code tested on grails 3.1.4


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -