[英]spring oauth error Full authentication is required to access this resource
Our application is using spring security to secure the application,i just added one rest controller which supporting spring oauth security, for oauth token validation, will be called by some other application following are my controller code 我们的应用程序使用Spring Security来保护应用程序的安全,我刚刚添加了一个支持spring oauth安全性的rest控制器,用于oauth令牌验证,其他应用程序将调用以下控制器,这是我的控制器代码
@RestController
@EnableResourceServer
public class Controller extends BaseRestController{
@RequestMapping(value="/api/v1/public/insertData", method=RequestMethod.POST)
ResponseEntity<?> insertTPQueueData(TitleProcurementQueue queue,Authentication authentication) {
return null;
}
}
after adding spring oauth security i am getting following error for my other controller using spring security 添加spring oauth security后,我正在使用spring security的其他控制器收到以下错误
<oauth>
<error_description>
Full authentication is required to access this resource
</error_description>
<error>unauthorized</error>
</oauth>
Please help 请帮忙
When you put security in your project spring implement some filters, like Cors, basic auth etc.. So you need to tell spring how apply security in your resources. 在将安全性放入项目中时,spring会实现一些过滤器,例如Cors,基本身份验证等。因此,您需要告诉spring如何在资源中应用安全性。 enter link description here
在此处输入链接说明
need to create a class with @EnableWebSecurity and configure like this: 需要使用@EnableWebSecurity创建一个类并进行如下配置:
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/h2-console/**").permitAll()
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.anyRequest().authenticated()
.and()
.httpBasic()
.csrf().disable();
http.headers().frameOptions().sameOrigin();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.