Java 在Spring-Security-Oauth2中,受保护的资源在没有访问令牌的情况下被访问

Java 在Spring-Security-Oauth2中,受保护的资源在没有访问令牌的情况下被访问,java,spring-security,oauth-2.0,spring-security-oauth2,Java,Spring Security,Oauth 2.0,Spring Security Oauth2,在我的应用程序中,我实现了spring-security-oauth2。除一例外,所有的事情都很顺利 场景是,我登录到系统,我得到oauth2访问令牌。我请求我的受保护资源,通过提供该令牌,我得到结果。同样,我在没有任何头的情况下执行相同的请求(没有access_令牌),这次我还获得了受保护的资源 我的受保护资源相关代码: <http pattern="/**" create-session="never" entry-point-ref="oauthAuthentic

在我的应用程序中,我实现了spring-security-oauth2。除一例外,所有的事情都很顺利

场景是,我登录到系统,我得到oauth2访问令牌。我请求我的受保护资源,通过提供该令牌,我得到结果。同样,我在没有任何头的情况下执行相同的请求(没有access_令牌),这次我还获得了受保护的资源

我的受保护资源相关代码:

<http pattern="/**" create-session="never"
          entry-point-ref="oauthAuthenticationEntryPoint"       
          xmlns="http://www.springframework.org/schema/security">
        <anonymous enabled="true" />
        <intercept-url pattern="/users" access="IS_AUTHENTICATED_ANONYMOUSLY"/>

        <intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" />
        <custom-filter ref="customFilter" position="FORM_LOGIN_FILTER"/>
        <custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" />
        <access-denied-handler ref="oauthAccessDeniedHandler" />
    </http>
使用access_令牌,我获得客户机_id-“test1”和 在第一次请求之后,如果我在没有访问令牌的情况下执行相同的请求,我将再次获得相同的客户端\u id=“test1”

并且还可以访问资源

我尽力了,但代码中没有任何循环漏洞。 任何帮助都将不胜感激。

这对我很有用:

create session=“never”
更改为
create session=“无状态”

希望这有帮助

 Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
   System.out.println("----------->>>" + ((OAuth2Authentication) authentication).getAuthorizationRequest().getClientId());