Relative Content

Tag Archive for springspring-bootspring-security

Getting 403 for SecurityFilterChain for every end point

I am trying to setup Spring security in my learning project and I am unable to access to any of the end points. I am getting 403 for all end points. I looked at some of the existing SO questions and here’s what I have tried so far.

What is the problem with Security Config file or the Spring Boot Starter Security in Spring Boot Applications?

Ok so I am working on a spring boot application which uses java, JSP and MySQL database. Originally the Spring Starter Security posed issues such as not showing my own login/signup pages, authentication errors etc. Because of this, I removed the Security Config file, and my project was working fine.
Then I made changes to the project so that the Security Config file will work fine since authentication and security is necessary for a web application. Everything was working fine, the whole project was running perfectly. A week ago, I formatted my C Drive because I bought a new SSD, but the original drive did not hold the IDE or the Project files. This resulted in my web application throwing “Forbidden 403 Error” from the login page itself.
After going mad for the better part of the day, I just commented out the Security Config File and the Starter Security dependency, and voila, the project is running smoothly again.
Can someone please tell me why Spring security is so cumbersome. I have read other threads, but could not find a good answer. Or if I am doing something wrong?

RequestMatcher().authenticated does not block the intended URLs

I have been trying to build a forum using Spring. Some components of the forum require authentication, for which I am using Spring Security. I put these URLs in the requestMatchers().permitAll(). However, when I tried to enter an URL (localhost:8080/post/new/1234) that matches with the pattern, my access is still allowed. The followings are my securityconfiguration:

Spring Security 6 / Spring boot 3

I am working on a Spring Boot 3.3 application and using Spring Security 6 to secure my endpoints. I have configured the security as follows: