Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
return r;
}
+
+int pakfire_jwt_has_expired(const char* token) {
+ time_t expires_at = -1;
+ time_t now = -1;
+
+ // Fetch the current time
+ now = time(NULL);
+ if (now < 0)
+ return -errno;
+
+ // Fetch the expiry time of the token
+ expires_at = pakfire_jwt_expires_at(token);
+ if (expires_at < 0)
+ return expires_at;
+
+ // We consider the token as expired if there are less than 60 seconds left
+ return (expires_at - now) < 60;
+}
int pakfire_jwt_payload(const char* token, struct json_object** payload);
time_t pakfire_jwt_expires_at(const char* token);
+int pakfire_jwt_has_expired(const char* token);
#endif /* PAKFIRE_JWT_H */