@@ -349,23 +349,27 @@ int jwt_verify_body(char *body, zval *return_value)
349
349
err_msg = msg; \
350
350
} while(0);
351
351
352
- /* Expiration */
352
+ /* set expiration and not before */
353
+ JWT_G (expiration ) = jwt_hash_str_find_long (return_value , "exp" );
354
+ JWT_G (not_before ) = jwt_hash_str_find_long (return_value , "nbf" );
355
+ JWT_G (iat ) = jwt_hash_str_find_long (return_value , "iat" );
356
+
357
+ /* expiration */
353
358
if (JWT_G (expiration ) && (curr_time - JWT_G (leeway )) >= JWT_G (expiration ))
354
359
FORMAT_CEX_MSG ("Expired token" , jwt_expired_signature_cex );
355
360
356
361
/* not before */
357
362
if (JWT_G (not_before ) && JWT_G (not_before ) > (curr_time + JWT_G (leeway )))
358
363
FORMAT_CEX_TIME (JWT_G (not_before ), jwt_before_valid_cex );
359
364
365
+ /* iat */
366
+ if (JWT_G (iat ) && JWT_G (iat ) > (curr_time + JWT_G (leeway )))
367
+ FORMAT_CEX_TIME (JWT_G (iat ), jwt_invalid_iat_cex );
368
+
360
369
/* iss */
361
370
if (jwt_verify_claims_str (return_value , "iss" , JWT_G (iss )))
362
371
FORMAT_CEX_MSG ("Invalid Issuer" , jwt_invalid_issuer_cex );
363
372
364
- /* iat */
365
- if (JWT_G (iat ) && JWT_G (iat ) > (curr_time + JWT_G (leeway ))) {
366
- FORMAT_CEX_TIME (JWT_G (iat ), jwt_invalid_iat_cex );
367
- }
368
-
369
373
/* jti */
370
374
if (jwt_verify_claims_str (return_value , "jti" , JWT_G (jti )))
371
375
FORMAT_CEX_MSG ("Invalid Jti" , jwt_invalid_jti_cex );
@@ -462,11 +466,6 @@ static void php_jwt_encode(INTERNAL_FUNCTION_PARAMETERS) {
462
466
goto encode_done ;
463
467
}
464
468
465
- /* set expiration and not before */
466
- JWT_G (expiration ) = jwt_hash_str_find_long (payload , "exp" );
467
- JWT_G (not_before ) = jwt_hash_str_find_long (payload , "nbf" );
468
- JWT_G (iat ) = jwt_hash_str_find_long (payload , "iat" );
469
-
470
469
/* init */
471
470
array_init (& header );
472
471
0 commit comments