Coder Social home page Coder Social logo

api-rest-php's Introduction

Instrucciones

Inicio del servidor REST API:

    php -S localhost:8000 router.php
    npm run serve

AUTH

Para utilizar los diferentes métodos de auth es necesario descomentar, según sea requerido, las siguientes líneas:

    /*Autenticacion via HTTP */
    include('auth/http.php');

    /* Autenticacion via HMAC */
    include('auth/hmac.php');

    /* Autenticacion via Token */
    include('auth/token.php');

Auth HTTP: Para utilizar este método, es necesario tener el módulo http.php activado y correr el siguente comando:

    curl "http://<user>:<pwd>@localhost:8000/books"
    
    npm run auth:http

** Los campos <user> y <pwd> se configuran dentro del módulo http.php.

Auth HMAC: Para utilizar este método, es necesario tener el módulo hmac.php y generar un hash con:

    php auth/hmac-hash.php <uid>
    npm run auth:hmac:hash

Para consultar es necesario correr el siguiente comando CURL, utilizando los datos obtenidos por el hmac-hash.php:

    curl http://localhost:8000/books -H 'X-HASH: <hash>' -H 'X-UID: <uid>' -H 'X-TIMESTAMP: <time>'

Auth Token: Para utilizar este método, es necesario tener el módulo token.php, ademas se debe correr el servidor de auth con el siguiente comando:

    php -S localhost:8001 auth/auth-serve.php
    npm run auth:serve:token

Para obtener el Token del servidor es necesario correr el siguiente comando:

    curl http://localhost:8001 -X 'POST' -H 'X-Client-Id: <uid>' -H 'X-Secret:<secret>'

** Los campos <uid> y <secret> se configuran dentro del servidor auth-serve.php.

Copiamos el Token obtenido por el comando, y para realizar la consultar hay que correr el siguiente comando:

    curl http://localhost:8000/books -H 'X-Token: <token>'

api-rest-php's People

Contributors

gonpineiro avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.