Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

spring security authorisation

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Bookmark Topic Watch Topic
  • New Topic