How to add Content Security Policy headers for login page in Spring Security xml configuration?

Viewed 673

I am trying to add Content Security Policy header property for all security filters in my Spring web app, I am being able to add them using headers element tag in http element of Spring Security for generic security filter, but for security filters of login page, css etc, I am not being able to add them as Spring Security doesn't allow any element inside an http tag if its security tag is set to "none". Also If I doesn't set it to "none" (to add the required headers) the web app doesn't compile properly giving "not configured for login-page" error. Following is the configuration I am using right now:

  <http pattern="/css/**" security="none"/>
  <http pattern="/login.jsp*" security="none"/>

  <http auto-config='true'>
     <security:headers>
        <security:header name="X-Content-Security-Policy" value="default-src 'self'"/>
        <security:header name="X-WebKit-CSP" value="default-src 'self'"/>
     </security:headers>
    <intercept-url pattern="/**" access="ROLE_USER" />
    <form-login login-page='/login.jsp'/>
  </http>

How should I resolve this, I am using this documentation. Thank you. ;-)

0 Answers
Related