简体   繁体   English

spring oauth错误,需要完全认证才能访问此资源

[英]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.

相关问题 Spring-Security-Oauth2:访问此资源需要完全身份验证 - Spring-Security-Oauth2: Full authentication is required to access this resource Spring Security OAuth - 访问此资源需要完全身份验证 - Spring Security OAuth - Full authentication is required to access this resource Spring OAuth2“访问此资源需要完全身份验证” - Spring OAuth2 “Full authentication is required to access this resource” 在 Oauth2 Spring Boot 中访问此资源需要完全身份验证 - Getting Unauthorised Full authentication is required to access this resource in Oauth2 Spring Boot 未经授权的错误:需要完全身份验证才能访问此资源 - Unauthorized error: Full authentication is required to access this resource 错误未经授权,需要完全验证才能访问此资源 - Error Unauthorized, Full authentication is required to access this resource Spring Boot 2: {&quot;error&quot;:&quot;unauthorized&quot;,&quot;error_description&quot;:&quot;访问此资源需要完整身份验证&quot;} - Spring Boot 2: {"error":"unauthorized","error_description":"Full authentication is required to access this resource"} 使用Spring Security和Keycloak访问此资源需要完全认证 - Full authentication is required to access this resource with Spring Security and Keycloak 测试弹簧安全站。 需要完全认证才能访问此资源 - Testing spring security post. Full authentication is required to access this resource 未经授权的错误:需要完全身份验证才能使用 spring.security v.6 访问此资源 - Unauthorized error: Full authentication is required to access this resource with spring.security v.6
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM