codigo5/silex-jwt

Name: silex-jwt

Owner: Codigo5

Description: Library for JWT work on Silex

Forked from: ofat/silex-jwt

Created: 2017-03-30 20:34:05.0

Updated: 2017-03-30 20:34:07.0

Pushed: 2017-03-30 21:53:23.0

Homepage: null

Size: 10

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Silex JWT

Library for work with JWT on Silex framework.

You can generate and check JWT tokens, use middleware for auth checking.

Installation

composer require ofat\silex-jwt

Usage
  1. Register service provider:
p

Ofat\SilexJWT\JWTAuth;
Silex\Application;

art our application
 = new Silex\Application();

gister silex jwt service provider. Add jwt secret key
->register(new JWTAuth(),[
'jwt.secret' => 'test'


ample of jwt generating
->post('/login', function(Request $request) use ($app) {
$userId = 1;
$token = $app['jwt_auth']->generateToken($userId);

return $app->json(['token' => $token]);


ample of checking json web token
->get('/test', function(Request $request) use ($app) {
return $app->json(['test' => true]);
before(new JWTTokenCheck());


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.