Spring Oauth 2访问被拒绝,作用域投票者返回0

Spring Oauth 2访问被拒绝,作用域投票者返回0,spring,oauth,Spring,Oauth,您好,我正在尝试为我的应用程序实现oAuth2,尽管我实现了所有东西,但身份验证存在问题 以下是我尝试在安全上下文中进行身份验证的方式: <http pattern="/rest/formValue/**" create-session="never" entry-point-ref="oauthAuthenticationEntryPoint" access-decision-manager-ref="accessDecisionManager" xmlns="http://www.sp

您好,我正在尝试为我的应用程序实现oAuth2,尽管我实现了所有东西,但身份验证存在问题

以下是我尝试在安全上下文中进行身份验证的方式:

<http pattern="/rest/formValue/**" create-session="never" entry-point-ref="oauthAuthenticationEntryPoint"
access-decision-manager-ref="accessDecisionManager" xmlns="http://www.springframework.org/schema/security">
    <anonymous enabled="false" />
    <intercept-url pattern="/rest/formValue/**" access="ROLE_USER,ROLE_ADMIN" />
    <custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" />
    <access-denied-handler ref="oauthAccessDeniedHandler" />
</http>
我正在我的用户角色表中使用角色管理

当我尝试访问/formValue/1112时,我在控制台中遇到了这个错误

13:31:51.362 [http-bio-8080-exec-3] DEBUG o.s.s.w.a.i.FilterSecurityInterceptor - Previously Authenticated: org.springframework.security.oauth2.provider.OAuth2Authentication@2b595da3: Principal: org.springframework.security.core.userdetails.User@f276d6fe: Username: sahinyanlik@hotmail.com; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMIN; Credentials: [PROTECTED]; Authenticated: true; Details: remoteAddress=0:0:0:0:0:0:0:1, , tokenValue=<TOKEN>; Granted Authorities: ROLE_ADMIN
13:31:51.363 [http-bio-8080-exec-3] DEBUG o.s.s.access.vote.UnanimousBased - Voter: org.springframework.security.oauth2.provider.vote.ScopeVoter@4d2979be, returned: 0
13:31:51.363 [http-bio-8080-exec-3] DEBUG o.s.s.access.vote.UnanimousBased - Voter: org.springframework.security.access.vote.RoleVoter@5df7d085, returned: -1


13:31:51.371 [http-bio-8080-exec-3] DEBUG o.s.s.w.a.ExceptionTranslationFilter - Access is denied (user is not anonymous); delegating to AccessDeniedHandler
13:31:51.362[http-bio-8080-exec-3]调试o.s.s.w.a.i.FilterSecurityInterceptor-以前经过身份验证的:org.springframework.security.oauth2.provider。OAuth2Authentication@2b595da3:Principal:org.springframework.security.core.userdetails。User@f276d6fe:用户名:sahinyanlik@hotmail.com; 密码:[受保护];启用:真;AccountNoExpired:正确;无需证明的凭证:真实;AccountNonLocked:true;授予的权限:角色\管理员;凭据:[受保护];认证:正确;详细信息:remoteAddress=0:0:0:0:0:0:1,tokenValue=;授予的权限:角色\管理员
13:31:51.363[http-bio-8080-exec-3]调试o.s.s.access.vote.UnanimousBased-Voter:org.springframework.security.oauth2.provider.vote。ScopeVoter@4d2979be,返回时间:0
13:31:51.363[http-bio-8080-exec-3]调试o.s.s.access.vote.UnanimousBased-投票人:org.springframework.security.access.vote。RoleVoter@5df7d085,返回:-1
13:31:51.371[http-bio-8080-exec-3]调试o.s.s.w.a.例外TranslationFilter-访问被拒绝(用户不是匿名的);委托给AccessDeniedHandler
org.springframework.security.access.AccessDeniedException:访问被拒绝

以前我检查过,但我不知道,因为当我使用这样的东西时

<intercept-url pattern="/oauth/clients/.*" access="oauthClientHasRole('ROLE_CLIENT') and oauthIsClient() and oauthHasScope('read')"  method="GET" />

我得到一个错误,说明我不能使用oauthClientHasRole“


谢谢。

我通过更改

<intercept-url pattern="/rest/formValue/**" access="ROLE_USER,ROLE_ADMIN" />



我通过调试发现了问题。

我通过更改

<intercept-url pattern="/rest/formValue/**" access="ROLE_USER,ROLE_ADMIN" />


我通过调试发现了问题

<intercept-url pattern="/rest/formValue/**" access="SCOPE_READ" />