2017 © Pedro Peláez
 

library guzzle-jwt

This package contains useful classes and interfaces for requiring a JWT token

image

webthink/guzzle-jwt

This package contains useful classes and interfaces for requiring a JWT token

  • Tuesday, June 26, 2018
  • by gmponos
  • Repository
  • 1 Watchers
  • 3 Stars
  • 1,536 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 59 % Grown

The README.md

A guzzle middleware for JWT authentication.

codecov Build Status SensioLabsInsight MIT licensed, (*1)

Goal of this package is to provide a set of useful classes in order to use a JWT authentication with Guzzle., (*2)

Install

You can install the package using composer, (*3)

composer require webthink/guzzle-jwt, (*4)

Usage

Basic Usage

As a first step you need to implement your own Authenticator., (*5)

``` php class MyAuthenticator implements AuthenticatorInterface { public function authenticate($username, $password) { // code.. and return a TokenInterface. } }, (*6)


Then you need to append into your handler stack the middleware provided by the package. ``` php // Your handler stack $stack = HandlerStack::create(); // Add middleware $stack->append(new Middleware($myAuthenticator)); $httpClient = new Client([ 'handler' => $stack, 'jwt' => [ 'username' => 'username', 'password' => 'password', ], ]); $response = $httClient->get('/my_api_that_requires_jwt_token');

NOTE, (*7)

I will not proceed with creating classes that implement the AuthenticatorInterface. The AuthenticatorInterface can be implemented by the developer who uses the package., (*8)

Storages

Storages are a way of caching JWT between multiple requests. Depending on the storage the token can for using it for more than one HTTP Request., (*9)

In order to use the storage you will need either to implement an Authenticator of your own that will use the storage or use the StoreAuthenticator, (*10)

php $myAuthenticator = new MyAuthenticator(); $storeAuthenticator = new StoreAuthenticator($myAuthenticator, new MemoryStorage());, (*11)

Then you can pass the store authenticator in the middleware and follow the procedure described above., (*12)

Contributing

Feel free to comment on anything you might believe it's going in the wrong direction or even better contribute with a PR., (*13)

Todo

  • Increase UnitTests.
  • Investigate the possibility of including some authenticators.

Credits

License

The MIT License (MIT). Please see License File for more information., (*14)

The Versions

26/06 2018

dev-master

9999999-dev https://github.com/webthinkgr/guzzleJwt

This package contains useful classes and interfaces for requiring a JWT token

  Sources   Download

proprietary

The Requires

 

The Development Requires

jwt guzzle webthink

26/06 2018

v0.4.0

0.4.0.0 https://github.com/webthinkgr/guzzleJwt

This package contains useful classes and interfaces for requiring a JWT token

  Sources   Download

proprietary

The Requires

 

The Development Requires

jwt guzzle webthink

15/09 2017

v0.3.0

0.3.0.0 https://github.com/webthinkgr/guzzleJwt

This package contains useful classes and interfaces for requiring a JWT token

  Sources   Download

proprietary

The Requires

 

The Development Requires

jwt guzzle webthink

14/09 2017

v0.2.0

0.2.0.0 https://github.com/webthinkgr/guzzleJwt

This package contains useful classes and interfaces for requiring a JWT token

  Sources   Download

proprietary

The Requires

 

The Development Requires

jwt guzzle webthink

02/09 2017

dev-increase_coverage

dev-increase_coverage https://github.com/gmponos/guzzleJwt

This package contains useful classes and interfaces for requiring a JWT token

  Sources   Download

proprietary

The Requires

 

The Development Requires

jwt guzzle webthink

02/08 2017

v0.1.0

0.1.0.0 https://github.com/gmponos/guzzleJwt

This package contains useful classes and interfaces for requiring a JWT token

  Sources   Download

proprietary

The Requires

 

The Development Requires

jwt guzzle webthink