posted 7 years ago
I implemented spring security in my project.the authentication part works fine.It selects users from dbs and logs in.However authorisation does not work.There are no errors on the console or anywhere,But the user with user role as ROLE_USER is able to access the ADMIN pages also.This is the spring-security.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd">
<!-- enable use-expressions -->
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/pqr/edit**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/pqr/list**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/pqr/newtopic**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/pqr/user**" access="hasRole('ROLE_USER')" />
<!-- access denied page -->
<access-denied-handler error-page="/pqr/403" />
<form-login
login-page="/login"
default-target-url="/dashboard"
always-use-default-target="false"
login-processing-url="/j_spring_security_check"
authentication-failure-url="/login?error"
username-parameter="username"
password-parameter="password" />
<logout logout-success-url="/login?logout" />
</http>
<authentication-manager>
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query=
"select username,password,enabled from users where username=?"
authorities-by-username-query=
"select username, role from roles where username =? " />
</authentication-provider>
</authentication-manager>
</beans:beans>
The user is able to access admin pages and admin is accessing user pages.How to solve this.I want user shouldnt acess admin URLs