From 3076e88e43c3c03b8780df11f5ffa3abeeac8fef Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Sat, 25 May 2019 22:45:38 +0000 Subject: [PATCH] authjwt : Update property name git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5291 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- authjwt.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/authjwt.php b/authjwt.php index 5e38356..d65dc5a 100644 --- a/authjwt.php +++ b/authjwt.php @@ -6,12 +6,15 @@ require_once ("domframework/jwt.php"); -/** User authentication against JSON Web Token */ +/** User authentication against JSON Web Token + * To use it, the $serverKey must be defined. It can be created by example, + * by using $serverKey = sha1 (microtime (true)); + */ class authjwt extends auth { /** The JSON Web Token Server key if used */ - public $jwtServerKey = null; + public $serverKey = null; /** If the user is valid, return the email in details */ @@ -41,7 +44,7 @@ class authjwt extends auth throw new \Exception ("No Bearer Authentication available", 401); $token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7); $jwt = new jwt (); - $payload = $jwt->decode ($token, $this->jwtServerKey); + $payload = $jwt->decode ($token, $this->serverKey); if (! key_exists ("email", $payload)) return null; // The JWT was tested in authparams. End of process