hashtopolis / server

Hashtopolis - distributed password cracking with Hashcat
GNU General Public License v3.0
1.44k stars 219 forks source link

[FEATURE]: Convert homebrew APIv2 interface to JSON:API standard #1018

Open rixvet opened 11 months ago

rixvet commented 11 months ago

Re-write APIv2 interface to adhere to JSON:API 1.1 standard (https://jsonapi.org/) this will future-proof the APIv2 for new features and allow for more compact response.

Related to:

zyronix commented 6 months ago

Also looks like there is a standard for this: https://datatracker.ietf.org/doc/html/rfc5988

The current status of this item:

In the current dev branch there is some pagination, however the server will fetch all data even if you just request two pages.

Please see: https://github.com/hashtopolis/server/blob/dev/src/inc/apiv2/common/AbstractModelAPI.class.php#L298

In the feature branch of this issue this already has been partially implemented: https://github.com/hashtopolis/server/blob/feature/1018-convert-homebrew-apiv2-interface-to-jsonapi-standard/src/inc/apiv2/common/AbstractModelAPI.class.php#L345

https://github.com/hashtopolis/server/blob/feature/1018-convert-homebrew-apiv2-interface-to-jsonapi-standard/src/inc/apiv2/common/AbstractModelAPI.class.php#L353

This need to be synced with the current dev branch. There needs to be some implementation of 'start-from-filter' in the SQL queries.

Beside the pagination, fetching of related object should also be done with the json-api standard (include).

Summary:

Attached branch: https://github.com/hashtopolis/server/blob/feature/1018-convert-homebrew-apiv2-interface-to-jsonapi-standard

jessevz commented 3 weeks ago

I have been looking into this and it seems to me that all these points have already been implemented in this feature branch. The only thing that I found that is not according to the JSON API specification is the pagination. For example in the feature branch you can paginate with the following query: http://localhost:8080/api/v2/ui/tasks?page[after]=1&page[size]=2. But according to the spec this should be done as follows: http://localhost:8080/api/v2/ui/tasks?page[offset]=1&page[limit]=2. But this should be a relative easy fix. I could try to fix that and merge it with the dev branch if needed?