Spring OAuth2无法正确验证用户身份

时间:2019-07-03 06:35:22

标签: angular shibboleth spring-oauth2

我有一个Angular应用,它使用身份验证代码流通过oauth2登录到我的后端。

当用户登录时,他被重定向到登录页面(shiboleth),并且在应用程序继续执行后,流程通过调用/ oauht / token URL要求访问令牌。

此过程在开发模式下有效,当我部署应用程序时,调用/ oauth / token URL时出现错误403。

调试后,我在日志中发现了该错误:

var item = event.getSource(); //return Table

如日志中所示,spring正在验证USER hasAnyAuthority!这是一个探针,他应该在客户端应用程序(angular)而不是用户!!上进行此验证!

在开发模式下调试时,该过程正确完成了!!

我不明白为什么?

Jul 02 12:32:30 test-2 java[20962]: 2019-07-02 12:32:30.115 DEBUG 20962 --- [.1-16100-exec-1] o.s.s.w.a.i.FilterSecurityInterceptor    : Secure object: FilterInvocation: URL: /oauth/token; Attributes: [hasAnyAuthority('TRUSTED_CLIENT')]
Jul 02 12:32:30 test-2 java[20962]: 2019-07-02 12:32:30.115 DEBUG 20962 --- [.1-16100-exec-1] o.s.s.w.a.i.FilterSecurityInterceptor    : Previously Authenticated: DLCM Authentication [user=ch.dmm.service.DMMUserDetails@775e4c20, authenticated=true]
Jul 02 12:36:48 test-2 java[20962]: 2019-07-02 12:36:48.061 DEBUG 20962 --- [.1-16100-exec-1] o.s.s.access.vote.AffirmativeBased       : Voter: org.springframework.security.web.access.expression.WebExpressionVoter@88532f3, returned: -1
Jul 02 12:36:48 test-2 java[20962]: 2019-07-02 12:36:48.066 DEBUG 20962 --- [.1-16100-exec-1] o.s.s.w.a.ExceptionTranslationFilter     : Access is denied (user is not anonymous); delegating to AccessDeniedHandler

1 个答案:

答案 0 :(得分:0)

您需要将部署的应用程序URL添加到OAuth2客户端URL中。