title: How to enable csrf support for swagger-ui and swagger-codegen
body: <p>I have an application which is built using Spring Boot and Angular 6. I have also  generated API clients using <code>Swagger-codegen</code>. Everything was working fine but recently it was found that application was vulnerable to CSRF. So, I have implemented the CSRF token within cookie by using <code>CsrfTokenRepository</code> on server side, like this: </p>
  
  <pre><code>http.csrf().ignoringAntMatchers(CSRF_IGNORE).csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
  </code></pre>
  
  <p>and for Angular :</p>
  
  <pre><code>HttpClientXsrfModule.withOptions({cookieName: 'XSRF-TOKEN'}),
  </code></pre>
  
  <p>Now, the application is working fine, but the swagger-ui and generared API clients are not working. It throws:</p>
  
  <blockquote>
    <p>Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-XSRF-TOKEN'.</p>
  </blockquote>
  
  <p>I have searched for this and found some issues for <code>swagger</code> and <code>springfox-swagger-ui</code>. Particularly, this was very useful <a href="https://github.com/springfox/springfox/issues/1450" rel="nofollow noreferrer">https://github.com/springfox/springfox/issues/1450</a>. But I didn't found any idea about how can I use this or is this possible or not. On most of the other places, developers are ignoring <code>swagger-ui</code> from CSRF. </p>
  
  <p>Any help will be appreciated.</p>
  
  <p>Thanks</p>