2017 © Pedro Peláez
 

library securejwt

Secure JWT

image

geggleto/securejwt

Secure JWT

  • Wednesday, June 1, 2016
  • by geggleto
  • Repository
  • 1 Watchers
  • 3 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Encrypt your JSON Web Tokens

Pre-Req

Libsodium is installed and configured in your environment. Our friends over at ParagonIE have a wonderful document to help you out. Read it here., (*1)

Installation

composer require geggleto/securejwt

Usage

  1. Generate a security key [a script has been provided scripts/generateSecretKey.php], (*2)

  2. Encrypting your Tokens, (*3)


$config = new \Lcobucci\JWT\Builder(); // This object helps to simplify the creation of the dependencies // instead of using "?:" on constructors. $token = $config->setIssuer('http://example.com') // Configures the issuer (iss claim) ->setAudience('http://example.org') // Configures the audience (aud claim) ->setId('4f1g23a12aa', true) // Configures the id (jti claim), replicating as a header item ->setIssuedAt(time()) // Configures the time that the token was issue (iat claim) ->setNotBefore(time() + 60) // Configures the time that the token can be used (nbf claim) ->setExpiration(time() + 3600) // Configures the expiration time of the token (exp claim) ->set('uid', 1) // Configures a new claim, called "uid" ->getToken(); // Retrieves the generated token $secureJwt = new \SecureJwt\SecureJwt('./sec/encryption.key'); $securedToken = $secureJwt->encryptToken((string)$token); //<--- This is the encrypted token
  1. Decrypting your tokens
    $tokenString = $secureJwt->decryptToken($securedToken);

    $newToken = (new \Lcobucci\JWT\Parser())->parse($tokenString);

The Versions

01/06 2016

dev-master

9999999-dev

Secure JWT

  Sources   Download

MIT

The Requires

 

The Development Requires

27/05 2016

0.0.1

0.0.1.0

Secure JWT

  Sources   Download

MIT

The Requires

 

The Development Requires