2017 © Pedro Peláez
 

library jose

JWT, JWS and JWS implementation in PHP

image

gree/jose

JWT, JWS and JWS implementation in PHP

  • Wednesday, September 14, 2016
  • by nov
  • Repository
  • 8 Watchers
  • 75 Stars
  • 142,928 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 34 Forks
  • 4 Open issues
  • 13 Versions
  • 18 % Grown

The README.md

JOSE

PHP JOSE (Javascript Object Signing and Encryption) Implementation, (*1)

Build Status, (*2)

Requirements

phpseclib is required. http://phpseclib.sourceforge.net, (*3)

Example

JWT

Encoding

$jwt = new JOSE_JWT(array(
    'foo' => 'bar'
));
$jwt->toString();

Decoding

$jwt_string = 'eyJ...';
$jwt = JOSE_JWT::decode($jwt_string);

JWS

Signing

$private_key = "-----BEGIN RSA PRIVATE KEY-----\n....";
$jwt = new JOSE_JWT(array(
    'foo' => 'bar'
));
$jws = $jwt->sign($private_key, 'RS256');

NOTE: $private_key can be phpseclib\Crypt\RSA instance., (*4)

Verification

$public_key = "-----BEGIN RSA PUBLIC KEY-----\n....";
$jwt_string = 'eyJ...';
$jws = JOSE_JWT::decode($jwt_string);
$jws->verify($public_key, 'RS256');

NOTE: $public_key can be JOSE_JWK or phpseclib\Crypt\RSA instance., (*5)

JWE

Encryption

$jwe = new JOSE_JWE($plain_text);
$jwe->encrypt(file_get_contents('/path/to/public_key.pem'));
$jwe->toString();

Decryption

$jwt_string = 'eyJ...';
$jwe = JOSE_JWT::decode($jwt_string);
$jwe->decrypt($private_key);

JWK

Encode

RSA Public Key
$public_key = new phpseclib\Crypt\RSA();
$public_key->loadKey('-----BEGIN RSA PUBLIC KEY-----\n...');
JOSE_JWK::encode($public_key); # => JOSE_JWK instance
RSA Private Key
$private_key = new phpseclib\Crypt\RSA();
$private_key->setPassword($pass_phrase); # skip if not encrypted
$private_key->loadKey('-----BEGIN RSA PRIVATE KEY-----\n...');
JOSE_JWK::encode($private_key); # => JOSE_JWK instance

Decode

RSA Public Key
# public key
$components = array(
    'kty' => 'RSA',
    'e' => 'AQAB',
    'n' => 'x9vNhcvSrxjsegZAAo4OEuo...'
);
JOSE_JWK::decode($components); # => phpseclib\Crypt\RSA instance
RSA Private Key

Not supported., (*6)

Run Test

git clone git://github.com/nov/jose-php.git
cd jose
php composer.phar install --dev
./vendor/bin/phpunit -c test/phpunit.xml --tap

Copyright © 2013 Nov Matake & GREE Inc. See LICENSE for details., (*7)

The Versions

14/09 2016

dev-master

9999999-dev https://github.com/nov/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

14/09 2016

2.2.1

2.2.1.0 https://github.com/nov/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

05/08 2016

2.2.0

2.2.0.0 https://github.com/gree/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

04/12 2015

2.1.0

2.1.0.0 https://github.com/gree/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

08/09 2015

2.0.1

2.0.1.0 https://github.com/gree/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

10/08 2015

2.0.0

2.0.0.0 https://github.com/gree/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

10/08 2015

1.0.1

1.0.1.0 https://github.com/gree/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

03/10 2014

1.0.0

1.0.0.0 https://github.com/gree/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

30/10 2013

0.1.5

0.1.5.0 https://github.com/gree/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

28/10 2013

0.1.4

0.1.4.0 https://github.com/gree/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

28/10 2013

0.1.3

0.1.3.0 https://github.com/gree/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

01/07 2013

0.1.1

0.1.1.0 https://github.com/gree/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token

25/04 2013

0.1.0

0.1.0.0 https://github.com/gree/jose

JWT, JWS and JWS implementation in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

jwt jws json web token jwe jose json web signature json web encryption openid connect id token