【问题标题】:access_denied error for client user even though keycloak evaluation says permit即使 keycloak 评估说允许,客户端用户的 access_denied 错误
【发布时间】:2020-06-19 04:08:48
【问题描述】:

我有多个资源,每个资源都指向应用程序上的一个页面。我正在使用 keycloak (v10.0.2) 对请求进行身份验证。我有两个用户,管理员和客户。管理员可以访问所有资源,而客户只能访问少数资源。在为 keycloak 分配权限后,我在控制台上进行了评估,并确保按照我的意愿授予对资源的权限。

现在,以管理员身份访问应用程序时,所有资源都可以正常访问。但是当以客户端身份登录时,登录和几个页面工作正常,但其余页面失败 OAuth2AuthenticationProcessingFilter。以下是日志中的消息。

DEBUG o.s.security.web.FilterChainProxy.doFilter - /services/customerAPI/listOfCustomers at position 6 of 12 in additional filter chain; firing Filter: 'OAuth2AuthenticationProcessingFilter'
DEBUG o.s.s.o.p.a.OAuth2AuthenticationProcessingFilter.doFilter - Authentication request failed: error="access_denied", error_description="Invalid token does not contain resource id (ums)"
DEBUG o.s.s.w.h.writers.HstsHeaderWriter.writeHeaders - Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@8ff0a24
DEBUG o.s.s.o.p.e.DefaultOAuth2ExceptionRenderer.writeWithMessageConverters - Written [error="access_denied", error_description="Invalid token does not contain resource id (ums)"] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@5adada73]
DEBUG o.s.s.w.c.SecurityContextPersistenceFilter.doFilter - SecurityContextHolder now cleared, as request processing completed

有人可以帮我找出我做错了什么吗?

【问题讨论】:

  • 我之前遇到过类似的问题(使用 Keycloak 评估),就我而言,我通过更改资源服务器 -> 授权 -> 设置 -> 决策策略来解决它
  • @YuriyP 设置为肯定。此外,评估表明这些资源是允许客户用户使用的。

标签: authentication oauth-2.0 keycloak access-token spring-security-oauth2


【解决方案1】:

将默认客户端角色 uma_protection 分配给“客户端”用户解决了该问题。

【讨论】:

    猜你喜欢
    • 2022-06-25
    • 2023-02-05
    • 2019-11-11
    • 2018-08-12
    • 1970-01-01
    • 2019-10-26
    • 2020-05-02
    • 1970-01-01
    • 2019-07-16
    相关资源
    最近更新 更多