我在基於Spring MVC的Web應用程序中設置了Spring Security。但由於某些外部系統限制,我希望用戶roles
爲小寫。Spring Security:不區分大小寫的角色
但是測試使用本地內存中時,用戶,應用程序只允許在身份驗證的用戶UPPER_CASE具有角色的訪問,並儘快更改角色爲小寫給403。
有沒有這樣的限制有隻在大寫的角色。我在文檔中找不到任何提及的內容?
我還發現有關屬性lowercase-comparisons
filter-invocation-definition-source
..這是爲了比較URL或角色?
下面是FilterSecurityInterceptor定義:
<bean id="fsi" class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor">
<property name="authenticationManager" ref="authenticationManager" />
<property name="accessDecisionManager" ref="accessDecisionManager" />
<property name="objectDefinitionSource">
<sec:filter-invocation-definition-source lowercase-comparisons="true">
<sec:intercept-url pattern="/logout.jsp" access="ROLE_ANONYMOUS" />
<sec:intercept-url pattern="/welcome.htm" access="ROLE_executer,ROLE_viewer,ROLE_admin_user" />
<!-- Write Access -->
<sec:intercept-url pattern="/addNewRecord.htm" access="ROLE_executer,ROLE_admin_user" />
<sec:intercept-url pattern="/updateRecord.htm" access="ROLE_executer,ROLE_admin_user" />
<sec:intercept-url pattern="/deleteRecord.htm" access="ROLE_executer,ROLE_admin_user" />
<sec:intercept-url pattern="/uploadFile.htm" access="ROLE_executer,ROLE_admin_user" />
<!-- Read Access to All Other-->
<sec:intercept-url pattern="/**" access="ROLE_executer,ROLE_viewer,ROLE_admin_user"/>
</sec:filter-invocation-definition-source>
</property>
</bean>
感謝您的幫助。
這是正確的。值得指出的另一件事是,這些「角色」不是典型意義上的角色(角色/特權)。這些僅僅是以String表示的GrantedAuthority。 RoleVoter檢查用戶授權中是否存在這些授權的權限。 – Shailendra
如果你想要他們,他們可以是「典型的角色」。 'GrantedAuthority'只是一個內部接口,它的含義取決於選民。 'RoleVoter'只是將字符串表示與爲URL或安全方法列出的訪問控制屬性進行比較,這是對應用程序中基於角色訪問的典型解釋。 –