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

Multiple user use same token. How to avoid it? #75

Open
ssboopathi1991 opened this issue Aug 18, 2017 · 1 comment
Open

Multiple user use same token. How to avoid it? #75

ssboopathi1991 opened this issue Aug 18, 2017 · 1 comment

Comments

@ssboopathi1991
Copy link

ssboopathi1991 commented Aug 18, 2017

I am new for JWT. I have created a token for one user. But other users can also use the same token, it's not validating. So how to create token based on the user?

$user_data = "user details";//EG: my id => 23
$token = JWTAuth::fromUser($user_data);

And also I have checked the token using the following line

$check_auth = JWTAuth::toUser($token);
@JosephmBassey
Copy link

It's impossible for multiple users to have same token, at least to my understanding;
a valid JSON Web Tokens consist of three parts separated by dots (.), which are:

  • Header: The header typically consists of two parts: the type of the token, which is JWT, and the signing algorithm being used, such as HMAC SHA256 or RSA
  • Payload: The second part of the token is the payload, which contains the claims. Claims are statements about an entity (typically, the user) for example username, _id, email etc.
  • Signature: To create the signature part you have to take the encoded header, the encoded payload, a secret, the algorithm specified in the header, and sign that

you can read more on Introduction to JSON Web Tokens

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

No branches or pull requests

2 participants