File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,16 @@ public static function decode(
127
127
if (!$ payload instanceof stdClass) {
128
128
throw new UnexpectedValueException ('Payload must be a JSON object ' );
129
129
}
130
+ if (isset ($ payload ->iat ) && !\is_numeric ($ payload ->iat )) {
131
+ throw new UnexpectedValueException ('Payload iat must be a number ' );
132
+ }
133
+ if (isset ($ payload ->nbf ) && !\is_numeric ($ payload ->nbf )) {
134
+ throw new UnexpectedValueException ('Payload nbf must be a number ' );
135
+ }
136
+ if (isset ($ payload ->exp ) && !\is_numeric ($ payload ->exp )) {
137
+ throw new UnexpectedValueException ('Payload exp must be a number ' );
138
+ }
139
+
130
140
$ sig = static ::urlsafeB64Decode ($ cryptob64 );
131
141
if (empty ($ header ->alg )) {
132
142
throw new UnexpectedValueException ('Empty algorithm ' );
@@ -172,7 +182,7 @@ public static function decode(
172
182
}
173
183
174
184
// Check if this token has expired.
175
- if (isset ($ payload ->exp ) && ($ timestamp - static ::$ leeway ) >= $ payload ->exp ) {
185
+ if (isset ($ payload ->exp ) && floor ( $ payload -> exp ) && ($ timestamp - static ::$ leeway ) >= $ payload ->exp ) {
176
186
$ ex = new ExpiredException ('Expired token ' );
177
187
$ ex ->setPayload ($ payload );
178
188
throw $ ex ;
You can’t perform that action at this time.
0 commit comments