Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shaarli API first step #616

Closed
wants to merge 3 commits into from
Closed

Conversation

ArthurHoaro
Copy link
Member

@ArthurHoaro ArthurHoaro commented Jul 31, 2016

Related to #609:

  • Add the API settings in Shaarli administration and install forms (enabled/secret).
  • API implementation structure, with unit tests.
  • Implement 1 service for now: /info.
  • Plug the API to be able to reach it.

You can test it with any REST client with:

You can use this script to get a valid token easily (they're valid during 9 minutes):

<?php

function generateJwtToken($secret)
    {
        $header = base64_encode('{
            "typ": "JWT",
            "alg": "HS512"
        }');
        $payload = base64_encode('{
            "iat": '. time() .'
        }');
        $signature = hash_hmac('sha512', $header .'.'. $payload , $secret);
        return $header .'.'. $payload .'.'. $signature;
    }

echo generateJwtToken('jaimeLePate');

You can add this in you config file to get more info about the errors:

"dev": { "debug": true }

EDIT: @nodiscc regarding shaarli/api-documentation#1

cloc application/api
       4 text files.
       4 unique files.                              
       0 files ignored.

github.com/AlDanial/cloc v 1.70  T=0.01 s (308.8 files/s, 49942.3 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
PHP                              4             59            274            314
-------------------------------------------------------------------------------
SUM:                             4             59            274            314
-------------------------------------------------------------------------------

@ArthurHoaro ArthurHoaro added template HTML rendering in review API REST API labels Jul 31, 2016
@ArthurHoaro ArthurHoaro added this to the 0.8.0 milestone Jul 31, 2016
@ArthurHoaro ArthurHoaro self-assigned this Jul 31, 2016
API settings:
   - api.enabled
   - api.secret

The API settings will be initialized (and the secret generated) with an update method.
Only contains a single service: /info
<td>
<input type="checkbox" name="enableApi" id="enableApi" checked="checked">
<label for="enableApi">
&nbsp;Enable Shaarli's API.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+REST

@ArthurHoaro ArthurHoaro modified the milestones: 0.8.0, 0.8.1 Oct 12, 2016
@ArthurHoaro
Copy link
Member Author

Closing due to #655

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API REST API in review template HTML rendering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants