libjwt
libjwt copied to clipboard
Add iterator for grants.
Hi, This is not a bug.
Need : In a nginx module i need to copy all grants in a context.
Pb: I haven't the defined list of grant key in this module.
Solution: Add iterator on grants to copy all grants without specified list of key.
Code: void *jwt_get_grant_iterator(jwt_t *jwt, void *iter) { if (!jwt) { errno = EINVAL; return NULL; } errno = 0;
if (iter == NULL) {
return json_object_iter(jwt->grants);
}
return json_object_iter_next(jwt->grants, iter);
}
const char *jwt_iterator_key(void *iter) { return json_object_iter_key(iter); }
const char *jwt_iterator_value(void *iter) { json_t json = json_object_iter_value(iter); if (json == NULL) { return NULL; } return (const char)json_string_value(json); }
Best regards. Sebastien
Would you be able to implement this on a pull request, complete with test cases?
Thanks
Hi, no pb, i will do it. It is my first modification in github, that should takes a little over time.
Thanks Seb