簡體   English   中英

在Spring Security中配置自定義對象

[英]Configure a custom object in Spring Security

在spring security中是否有任何配置方式,因此,我可以在調用此代碼時獲取自定義的“USER”DAO類對象。

SecurityContextHolder.getContext().getAuthentication().getPrincipal();

使用DaoAuthenticationProvider執行此操作的最簡單方法

  1. 確保您的User dao對象擴展org.springframework.security.core.userdetails.UserDetails
  2. 實現您的org.springframework.security.core.userdetails.UserDetailsService並返回您的User dao對象
  3. 使用UserDetailsService配置DaoAuthenticationProvider

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM