Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring security unsupported configuration attributes

I have the following snippet

<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>

When i run this on server it throws an exception saying

Unsupported configuration attributes: [permitAll, permitAll, hasRole('ROLE_ADMIN'), hasRole('ROLE_ADMIN'), hasRole('ROLE_MEMBER'), hasRole('ROLE_MEMBER')]

here is my access-decision-manager bean within the same xml

<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>

If i remove the access-decision-manager-ref no exception is thrown the app launches correctly can anyone please advice?

like image 458
Vikash Balasubramanian Avatar asked Jun 28 '15 13:06

Vikash Balasubramanian


1 Answers

Since you are defining your own accessDecisionManager, I don't see WebExpressionVoter as one of the beans in its list. WebExpressionVoter resolves strings like permitAll(), hasRole(), hasAuthority(), etc. So, your accessDecisionManager bean should be:

<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>
like image 82
Amit Avatar answered Dec 05 '22 06:12

Amit