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

Token JWT Decode #174

Closed
aascagarwal opened this issue May 20, 2021 · 13 comments
Closed

Token JWT Decode #174

aascagarwal opened this issue May 20, 2021 · 13 comments

Comments

@aascagarwal
Copy link

Suggestion: The token contains the time stamp for start and end ('iat': 1621506724, 'exp': 1621507624) of token validation, this can help in invalid token check without calling the beneficiary api everytime

use pyjwt
Also this will allow to regenerate the otp automatically just before expiration (if auto is selected)

@pallupz
Copy link
Owner

pallupz commented May 20, 2021

Oh I dint know about this. Thank you!

@pallupz
Copy link
Owner

pallupz commented May 25, 2021

Hi @aascagarwal - Did you decode the JWT? I seem to be running into InvalidSignatureError

@pallupz
Copy link
Owner

pallupz commented May 25, 2021

If you're on Discord, could we have a quick chat sometime? ID: pallupz#5726

@aascagarwal
Copy link
Author

jwt.decode(token, options={"verify_signature": False})

@pallupz
Copy link
Owner

pallupz commented May 25, 2021

algorithm?

@pallupz
Copy link
Owner

pallupz commented May 25, 2021

oh wait.. got it

@aascagarwal
Copy link
Author

decoded = jwt.decode(token, options={"verify_signature": False})
print(decoded)
mobile = str(decoded['mobile_number'])
startTime = datetime.datetime.fromtimestamp(decoded['iat'])
d1 = (datetime.datetime.now() + datetime.timedelta(minutes=15)).replace(microsecond = 0)
print(d1)
print(startTime)

    difference = (d1 - startTime).total_seconds() / 60
    print(difference)

@pallupz
Copy link
Owner

pallupz commented May 25, 2021

when I encode it back, I am not getting the same result

@aascagarwal
Copy link
Author

that's because, you need the signature..
you can put the expiration logic as intended, this was just a dummy I wrote to verify.
Relying on the this might be an issue, as cowin now logs out abruptly if any other session is working or number of requests are more, hence beneficiary check would still be a better fail safe

@pallupz
Copy link
Owner

pallupz commented May 25, 2021

yea.. so at the moment, we can at best only predict when this will expire?

@pallupz
Copy link
Owner

pallupz commented May 25, 2021

no way to generate the next token, I assum

@aascagarwal
Copy link
Author

I have not tried that, but mostly no

@pallupz
Copy link
Owner

pallupz commented May 25, 2021

yea - I tried with different things for keys, but nothing has worked so far. and that'd be a dumb design anyway. was hoping maybe devs made a mistake somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants