Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

spring security authorisation

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic