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

exp time bug #18

Closed
kissIce opened this issue Nov 3, 2018 · 2 comments
Closed

exp time bug #18

kissIce opened this issue Nov 3, 2018 · 2 comments
Labels
bug Something isn't working

Comments

@kissIce
Copy link

kissIce commented Nov 3, 2018

I find a bug in php-cli mode. if code run in php-cli mode, the exp time can't valid. I think may be the C function to get time have problem . example: I use swoft framework and I have add middleware to valid token , and I set exp is time() + 10 . but 30 second after .it also can use

@kissIce
Copy link
Author

kissIce commented Nov 3, 2018

<?php
$hmackey = 123456;
$payload = ['data' => 'data', 'exp' => time() +10];

// build expired token
$token = jwt_encode($payload, $hmackey, 'HS256');

try{
    $decoded_token = jwt_decode('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoiZGF0YSIsImV4cCI6MTU0MTIzNTYyMX0.yGQFos2HNgGat400NcRqTMxmkSvOY8BmlGf-P0r17Wo', $hmackey, [ 'algorithm' => 'HS256']);
}catch (ExpiredSignatureException $e)
{
    echo 1;
}

if build expired token ,then it can't thow exception. but if annotation build expired token .then it can thow exception. like this:

<?php
//$hmackey = 123456;
//$payload = ['data' => 'data', 'exp' => time() +10];
//
//// build expired token
//$token = jwt_encode($payload, $hmackey, 'HS256');

try{
    $decoded_token = jwt_decode('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoiZGF0YSIsImV4cCI6MTU0MTIzNTYyMX0.yGQFos2HNgGat400NcRqTMxmkSvOY8BmlGf-P0r17Wo', $hmackey, [ 'algorithm' => 'HS256']);
}catch (ExpiredSignatureException $e)
{
    echo 1;
}

@kissIce kissIce closed this as completed Nov 3, 2018
@kissIce kissIce reopened this Nov 3, 2018
@cdoco cdoco added the bug Something isn't working label Nov 4, 2018
@cdoco
Copy link
Owner

cdoco commented Nov 4, 2018

This is a bug. I fixed this problem in the develop branch. You can switch to develop branch and recompile the extension. It should be available.

@cdoco cdoco closed this as completed in 19b95cc Nov 6, 2018
cdoco added a commit that referenced this issue Nov 6, 2018
FIx #18 - expiration time bug .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants