Our team has been asked to prevent JWT hijacking in our API. Our solution has been to store a "fingerprint" of the user's IP and user agent in our database and validate that on each request. When the user logs out, we delete the fingerprint.
There are some problems with this:
- users often don't logout
- users IPs change
If a user doesn't logout, their fingerprint will remain. When they come back to the application, if their IP has changed, they won't be able to login, because it appears they are a hijacker.
What is the best approach to implement this kind of fingerprinting? Should we not be using the user IP?