跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 求助帖: Spring Security 如何将 token 转换成 Authentication 类?
未分類
2 3 月 2022

求助帖: Spring Security 如何将 token 转换成 Authentication 类?

求助帖: Spring Security 如何将 token 转换成 Authentication 类?

資深大佬 : winRain 21

彦祖们,我最近在用 keycloak 做认证,后端使用 spring security 和 keycloak spring security adapter 进行安全保护。

当我使用 client 从 keycloak 获取到了 token ,用 token 去调用后端 api 的时候,在 KeycloakAuthenticationProcessingFilter 180 行中,是直接去 SecurityContext中拿到了未认证的 Authentication 。

我想知道 token 是什么时候转换成了 Authentication 并放进 SecurityContext 中去的?我能不能通过实现子类修改逻辑?

各位大佬帮帮忙。

大佬有話說 (3)

  • 資深大佬 : Oktfolio

    多看看源码吧,能找到的。
    class extends AbstractAuthenticationToken
    AuthenticationFilter#attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
    AuthenticationFilter#successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authentication)

  • 資深大佬 : damai0419

    keycloak 没用过。
    但 spring cloud gateway 和 security 结合的时候,是在 ServerSecurityContextRepository 的子类中进行转换操作的。

  • 主 資深大佬 : winRain

    谢谢两位老哥,我仔细看了下源码,已经找到原因了

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具