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