2017 © Pedro Peláez
 

library json-rpc-auth

Auth extension for JSON-RPC library

image

datto/json-rpc-auth

Auth extension for JSON-RPC library

  • Tuesday, December 15, 2015
  • by binwiederhier
  • Repository
  • 4 Watchers
  • 2 Stars
  • 7,574 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 6 % Grown

The README.md

JSON-RPC Auth Extension

This is an authentication and authorization extension for the php-json-rpc library. It provides the ability to authorize JSON-RPC requests before they reach the endpoint., (*1)

Examples

First write an authentication Handler:, (*2)

namespace Datto\JsonRpc\Auth;

use Datto\JsonRpc;

class BasicAuthHandler implements Handler
{
    public function canHandle($method, $arguments)
    {
        return isset($_SERVER['PHP_AUTH_USER']);
    }

    public function authenticate($method, $arguments)
    {
        // Don't do this in production. Using '===' is vulnerable to timing attacks!
        return $_SERVER['PHP_AUTH_USER'] === 'phil' && $_SERVER['PHP_AUTH_PW'] === 'superpass!';
    }
}

Once you have that, just use it like this. This example uses the Simple\Evaluator (see php-json-rpc-simple) as underlying mapping mechanism:, (*3)

$authenticator = new Authenticator(array(
    new BasicAuthHandler(),
    // ...
));

$server = new Server(new Auth\Evaluator(new Simple\Evaluator(), $authenticator));
echo $server->reply('...');

Requirements

  • PHP >= 5.3

Installation

"require": {
  "datto/json-rpc-auth": "~4.0"
}

License

This package is released under an open-source license: LGPL-3.0., (*4)

Author

Written by Chad Kosie and Philipp C. Heckel., (*5)

The Versions

15/12 2015

dev-master

9999999-dev http://www.datto.com

Auth extension for JSON-RPC library

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Philipp Heckel
by Chad Kosie

15/12 2015

4.0.0

4.0.0.0 http://www.datto.com

Auth extension for JSON-RPC library

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Philipp Heckel
by Chad Kosie