Last active
August 30, 2018 03:00
-
-
Save matheusb-comp/a6541324fb74aade555eda5eb15e8518 to your computer and use it in GitHub Desktop.
[TESTING] JWT Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbkBleGFtcGxlLmNvbSIsImlhdCI6MTUzNTIzOTAyMiwianRpIjowLCJjc3JmIjoiYWRtaW4tWFNSRi1UT0tFTiJ9.4oFiHq2dYePuQo0451LcfQ671ibwUZ0gnlu4c_enAdo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$middlewareGroups = [ | |
'api' => [ | |
'throttle:60,1', | |
// \App\Http\Middleware\EncryptCookies::class, | |
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, | |
\App\Http\Middleware\Cookie2Jwt::class, | |
\App\Http\Middleware\VerifyJwt::class, // The guard will to this | |
'bindings', | |
], | |
]; | |
Route::middleware('auth:api')->get('/user', function (Request $request) { | |
\Log::channel('stderr')->debug('Request: ' . $request); | |
$c = Cookie::get('api_cookie'); | |
$r = rand(0, 100); | |
\Log::channel('stderr')->debug('Got cookie: ' . $c); | |
\Log::channel('stderr')->debug('Generated: ' . $r); | |
Cookie::queue('api_cookie', 'rand' . $r, 10); | |
\Log::channel('stderr')->debug('##########'); | |
return $request->user(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment