Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: JWT IP bound for enhanced security #1158

Closed
wants to merge 1 commit into from

Conversation

ymohit1603
Copy link

@ymohit1603 ymohit1603 commented Sep 7, 2024

PR Fixes:

#1156

Checklist before requesting a review

  • I have performed a self-review of my code
  • I assure there is no similar/duplicate pull request regarding same issue

@MeerUzairWasHere
Copy link
Contributor

I think, he said, if someone steals my jwt. but you're passing ip in jwt also? or I'm missing anything?

@ymohit1603
Copy link
Author

ymohit1603 commented Sep 8, 2024

Yeah,in this case we are signing jwt with ip address along with the traditional payload thing in the middleware when we are verifying the signed jwt it will return us the payload and the previous ip address used to sign it and then we can check if current ip is equal to the ip that signed the jwt.I think there is no need to store ip address in db when we can just sign the token with ip itself (:

@ymohit1603
Copy link
Author

Although that person knows jwt but he doesn't know the secret used to sign and he will be unable to decode the jwt to get the ip

@MeerUzairWasHere
Copy link
Contributor

Makes sense.

@Smnthjm08
Copy link

Question: Wouldn't it be better if we store token and IP Address in redis? @ymohit1603

@ymohit1603
Copy link
Author

I am a bit confused why we need to store the JWT tokens in db. JWT is used for stateless authentication where we don't need to store the tokens in db or anywhere else , but instead we let clients keep it and we just need to verify the signature on server.
Although i think redis is a more efficient way for storing jwt than relational db.

@devsargam devsargam closed this Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants