在资源服务器配置类中重写configure方法,添加放行信息
使用了@EnableResouceServer,且继承了ResourceServerConfigurerAdapter的类作为资源服务器配置信息类
@Configuration
@EnableResourceServer
@EnableGlobalMethodSecurity(prePostEnabled = true)
class ResourceServerConfig : ResourceServerConfigurerAdapter() {
@Throws(Exception::class)
override fun configure(http: HttpSecurity) {
http.authorizeRequests()
// 允许 路径为/code/ 后面为任意信息的路径地址 不需要通过oauth2登录授权
.antMatchers("/code/**").permitAll()
.anyRequest().authenticated()
}
}
复制代码