I have a Spring Boot project with a login endpoint that generates a token for accessing other endpoints. When a user logs in from a specific device (browser or application), I want to add a security measure that prevents the generated token from being used on other devices. In other words, the token should only be valid for the device it was generated on.
For example:
User logs in from Device X and receives a token like **************. If the user tries to use the same token from Device Y or any other device, access to the endpoints should be denied. Currently, I have implemented an AllRequestFilter class to filter all requests. How can I add this device-specific security to my application?
Here are some specific requirements I have:
- The token should be tied to the device that generated it, preventing its use on other devices.
- The solution should work for both browser-based logins and logins from mobile applications.
- I want to implement this security measure at the API level, rather than relying on device identification on the client side.
I would appreciate any suggestions or ideas on how to implement this device-specific security feature in my Spring Boot application. Thank you in advance!