title: swagger ui with spring security
body: <p>I need specific role to access swagger ui</p>
  
  <p>snippet to access swagger-ui with role 2 ( tried following with no joy)</p>
  
  <pre><code>http
                  .csrf()
                  .disable()
                  .authorizeRequests()
                      .antMatchers("/api/**").hasAuthority("ROLE_ROLE1")
                      .antMatchers("/login/**").permitAll()
                  .antMatchers("/info/**").permitAll()
                  .antMatchers(
                          "/configuration/ui",
                          "/v2/api-docs",
                          "/swagger-resources",
                          "/configuration/security",
                          "/swagger-ui.html",
                          "/webjars/**").hasAuthority("ROLE_ROLE2")
                  .and()
                  .formLogin()
                  .loginPage("/login.html")
                          .loginProcessingUrl("/perform_login")
                          .defaultSuccessUrl("/swagger-ui.html", true)
                  .failureUrl("/login.html?error=true")
                  .and().logout().logoutSuccessUrl("/login.html")
  </code></pre>
  
  <p>Permit all  works - this checks all the resources are granted access</p>
  
  <pre><code>http
                  .csrf()
                  .disable()
                  .authorizeRequests()
                      .antMatchers("/api/**").hasAuthority("ROLE_ROLE1")
                      .antMatchers("/login/**").permitAll()
                  .antMatchers("/info/**").permitAll()
                  .antMatchers(
                          "/configuration/ui",
                          "/v2/api-docs",
                          "/swagger-resources",
                          "/configuration/security",
                          "/swagger-ui.html",
                          "/webjars/**").permitAll()
                  .and()
                  .formLogin()
                  .loginPage("/login.html")
                          .loginProcessingUrl("/perform_login")
                          .defaultSuccessUrl("/swagger-ui.html", true)
                  .failureUrl("/login.html?error=true")
                  .and().logout().logoutSuccessUrl("/login.html")
  </code></pre>
  
  <p>there is in memory user for role2</p>
  
  <pre><code>auth
                  .inMemoryAuthentication()
                  .withUser("user1").password("userpassword").roles("ROLE2");;
  </code></pre>
  
  <p>but when I login it doesnt bring up the swagger-ui , is there any thing missing            ?</p>
  
  <p>permitAll does show the swagger-ui
  any help appreciated</p>
  
  <p>I tried</p>
  
  <pre><code>http
                  .csrf()
                  .disable()
                  .requestMatchers().antMatchers(
                  "/swagger-ui.html",
                  "/swagger-resources",
                  "/configuration/ui",
                  "/configuration/security",
                  "/v2/api-docs",
                  "/webjars/**", "/**")
                  .and()
                  .authorizeRequests()
                      .antMatchers("/api/**").hasAuthority("ROLE_ROLE1")
                      .antMatchers("/login/**").permitAll()
                  .antMatchers("/info/**").permitAll()
                  .antMatchers(
                          "/swagger-ui.html",
                          "/swagger-resources",
                          "/configuration/ui",
                          "/configuration/security",
                          "/v2/api-docs",
                          "/webjars/**").hasRole("ROLE2")
  </code></pre>