我已经开发了一个弹簧启动和oauth2演示应用程序。我有三个应用程序如下。Swagger UI没有加载Oauth2
- 资源api:这将有我们需要保护的所有方法。
- 验证服务器:这是一个提供令牌的oauth2服务器
- UI:在通过验证服务器成功登录后,它将能够访问资源。
我有很少的资源(控制器)可以公开访问。但是当我试图访问这个swagger UI时,它会要求我进行完整的身份验证。当我添加下面的代码时,swagger页面即将到来,但不仅仅是整个页面中的一个下拉菜单,而且也被打破。
http
.anonymous() //allow anonymous access
.and()
.authorizeRequests()
.antMatchers("/shouldbepublic/**", "/swagger-ui**/**").permitAll().and() //this should be public resources
.formLogin().loginPage("/login").permitAll()
.and()
.requestMatchers().antMatchers("/login", "/oauth/authorize", "/oauth/confirm_access")
.and()
.authorizeRequests().anyRequest().authenticated();
你是否使用springfox-swagger-ui作为依赖项? –