diff --git a/srv/.lua/jwt.lua b/srv/.lua/jwt.lua index c7adcc0..6d1f317 100644 --- a/srv/.lua/jwt.lua +++ b/srv/.lua/jwt.lua @@ -253,6 +253,17 @@ function JWS.VerifyTable(jwtTable, key, algorithms) assert(type(jwtTable.header) == "table", "Parameter: 'jwtTable' does not contain a header table") assert(jwtTable.payload ~= nil, "Parameter: 'jwtTable' does not contain a payload") + -- Claims (optional) + if(jwtTable.payload.nbf ~= nil) then + assert(type(jwtTable.payload.nbf) == "number", "Claim: 'nfb' must be a number") + assert(jwtTable.payload.nbf <= GetDate(), "Claim: 'nfb' is not valid") + end + + if(jwtTable.payload.exp ~= nil) then + assert(type(jwtTable.payload.exp) == "number", "Claim: 'exp' must be a number") + assert(jwtTable.payload.exp >= GetDate(), "Claim: 'exp' must not be expired") + end + -- if no algorithms are specified, fall back onto the supported algorithms algorithms = algorithms or JWA.supported if type(algorithms) == "string" then algorithms = { algorithms } end @@ -435,4 +446,4 @@ JWT._Common = Common JWT._JWS = JWS JWT._JWA = JWA -return JWT \ No newline at end of file +return JWT