I am using the JWT
concept in Spring Boot
with Spring Security
. Everything works promising, System is able to generate a Token and validate it with spring security.
The issue with the current implementation is Anyone "user X" can update/view the record of "User Y" using his/her own token. It's just not about the user Info. For example:
There are two tables in the Database:
- User
- Car
I am keeping userId
in the car
entity.
Right now "User x" can access the car details of "User Y" using the "CarID". How should I restrict "User X" to do any kind of transaction in a database which belongs to him/her only.
I followed the following options
@PreAuthorize
- Adding
User-Agent
But none of them are helping me out. Any hint would be appreciable.