Relative Content

Tag Archive for javaspring-security

Spring Security 6 configuration with custom form login

I am building a Spring Boot application with an endpoint “/admin” which requires authentication in order to be accessed; all other endpoints should be accessible without authentication. Furthermore, the authenticated user should have the “ADMIN” authority if accessing any of the pages on the “/admin” endpoint. I use a custom login page as well as a custom failure handler and a custom success handler upon logging in. I need to keep in mind that other secure endpoints with different security configurations could be added in the future (example: an api endpoint with JWT authentication & authorization).

Why Sring Can’t resolve method ‘antMatchers’ in ‘ExpressionInterceptUrlRegistry’?

I’m trying to configure a Spring Security setup in my application, but encountering an issue with the antMatchers method in the WebSecurityConfiguration class. When trying to use antMatchers method within authorizeRequests, I’m encountering a compilation error stating “Cannot resolve method ‘antMatchers’ in ‘ExpressionInterceptUrlRegistry'”. I’ve tried referring to YouTube videos, documentation, and community forums, but haven’t found a solution yet. Here’s my configuration:

Java Spring Boot Authentication

I’m developing a Spring Boot application and encountering intermittent 500 Internal Server Error responses for certain GET requests. The issue is inconsistent, meaning the same endpoint might work sometimes and fail other times.

Java Springboot Authentication(I can figure it out if you can help please)

I’m developing a Spring Boot application and encountering intermittent 500 Internal Server Error responses for certain GET requests. The issue is inconsistent, meaning the same endpoint might work sometimes and fail other times. (I don’t know i’m so lost and just about desperate) I’ll give my code:

Spring Security – Principal is null

I’ve been banging my head against the wall trying to resolve this issue. I’m trying to retrieve the currently logged in user. I have an end-point of /login as shown below. The problem is at line 7. For some odd reason, this line returns null at other end-points but this current one, /login. For example, if I make a post request to /todos, this SecurityContextHolder will return null, but it will not be null in /login. Please help, thank you.