[英]Loading groups from LDAP using Spring Security
我需要授予LDAP中屬於組(ABCD)的用戶的訪問權限。 我能夠通過Spring LDAP安全性成功進行身份驗證,但是由於某些原因,組成員身份未加載。 嘗試登錄時出現“ 403訪問被拒絕”錯誤。 我確認該用戶的組未填充到“授權單位”中。
SecurityContextHolder.getContext().getAuthentication().getAuthorities();
有什么方法可以將用戶組加載到權限中? 這是我的春季安全配置。
<security:http auto-config="true" use-expressions="true">
<security:intercept-url pattern="/js/**"
access="true" />
<security:intercept-url pattern="/css/**"
access="true" />
<security:intercept-url pattern="/images/**"
access="true" />
<security:intercept-url pattern="/**"
access="hasRole('ABCD')" />
</security:http>
<security:ldap-server id="ldapServer" url="${ldap.url}" />
<security:authentication-manager alias="authenticationManager">
<security:ldap-authentication-provider
server-ref="ldapServer" user-dn-pattern="uid={0},ou=people,o=xxxx.com"
group-search-base="ou=groups,o=xxxx.com" />
</security:authentication-manager>
應該是這樣的:
<security:ldap-server id="ldapServer" url="${ldap.url}/o=xxxx.com" />
<security:authentication-manager alias="authenticationManager">
group-search-filter="member={0}"
group-search-base="ou=groups"
user-search-base="ou=people"
user-search-filter="uid={0}"
</security:authentication-manager>
您遇到的主要問題是group-search-filter
,它應該包含user
一些attribute
(帶有占位符),該attribute
是指當前用戶是成員的組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.