• 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 5 antMatcher not working as expected

 
Bartender
Posts: 1752
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a simple testing authentication set up, but it's allowing any user role to access the "hello" class. I'm using an online example as my learning point and the author didn't get it working correctly either...

Here's the override for configure:

 

But the URL using the user = demo (and admin role), still gets to the page: localhost:8088/rest/hello

I've tried various combinations of asterisks with the .antMatchers() method above, but I can't get the security to respect only the user role.

To get the password stuff to work at all, I also had to refactor the online example to use a Password encoder.

Thanks in advance,

-- mike

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not sure if your issue is resolved,


we had a similar issue recently, and its fixed by adding context-path property in application.properties.

1. so, if your applicatiion.properties has a context-path key then antmatchers should start with just path mapping (start with /)
2. if you don't have a context defined in application.properties, but with a RequestMapping in your restconroller, then antmatchers should always include context-path (again, start with /)

i hope this resolves your issue,

Note: there is a change in the context-path spring property with jdk 11

Thanks
Shiva
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic