Spring Security不支持的配置属性


问题内容

我有以下片段

<http use-expressions="true" auto-config="false"
        entry-point-ref="loginUrlAuthenticationEntryPoint"
        access-decision-manager-ref="accessDecisionManager" disable-url-rewriting="false">
        <!--<custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter"
            /> -->
        <custom-filter position="FORM_LOGIN_FILTER"
            ref="usernamePasswordAuthenticationFilter" />
        <custom-filter position="LOGOUT_FILTER" ref="tapLockFilter" />

        <intercept-url pattern="/session/**" access="permitAll" />
        <intercept-url pattern="/deviceregistration/**" access="permitAll" />
        <intercept-url pattern="/session/lock" access="hasRole('ROLE_MEMBER')" />
        <intercept-url pattern="/app/resources/admin*" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/app/SuperAppdashboard*" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/app/*" access="hasRole('ROLE_MEMBER')" />


        <!--<session-management invalid-session-url="/tizelytics/session/invalidSession"
            session-authentication-error-url="/tizelytics/session/accessDenied" session-authentication-strategy-ref="sas">
            </session-management> -->

        <session-management invalid-session-url="/session/invalidSession"
            session-authentication-error-url="/session/accessDenied"
            session-fixation-protection="none">
            <concurrency-control max-sessions="1"
                expired-url="/session/accessExpired" />
        </session-management>
</http>

当我在服务器上运行它时,抛出一个异常说

不支持的配置属性:[permitAll,permitAll,hasRole(’ROLE_ADMIN’),hasRole(’ROLE_ADMIN’),hasRole(’ROLE_MEMBER’),hasRole(’ROLE_MEMBER’)]

这是我在同一xml中的access-decision-manager bean

<beans:bean id="accessDecisionManager"
        class="org.springframework.security.access.vote.AffirmativeBased">
        <beans:constructor-arg>
            <beans:list>
                <beans:bean
                    class="org.springframework.security.access.vote.AuthenticatedVoter" />
                <beans:bean class="org.springframework.security.access.vote.RoleVoter" />
            </beans:list>
        </beans:constructor-arg>
</beans:bean>

如果我删除了access-decision-manager-ref,则 不会引发异常,该应用程序将正确启动,有人可以请教吗?


问题答案:

由于您是定义自己的accessDecisionManager,因此我看不出WebExpressionVoter它是其列表中的bean之一。WebExpressionVoter做出决议弦喜欢permitAll()hasRole()hasAuthority()等,所以,你accessDecisionManager的bean应该是:

<beans:bean id="accessDecisionManager"
        class="org.springframework.security.access.vote.AffirmativeBased">
        <beans:constructor-arg>
            <beans:list>
                <beans:bean
                    class="org.springframework.security.access.vote.AuthenticatedVoter" />
                <beans:bean class="org.springframework.security.access.vote.RoleVoter" />
                <beans:bean class="org.springframework.security.web.access.expression.WebExpressionVoter" />
            </beans:list>
        </beans:constructor-arg>
</beans:bean>