authjwt : Update property name

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5291 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2019-05-25 22:45:38 +00:00
parent 569be5d418
commit 3076e88e43

View File

@@ -6,12 +6,15 @@
require_once ("domframework/jwt.php"); 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 class authjwt extends auth
{ {
/** The JSON Web Token Server key if used /** The JSON Web Token Server key if used
*/ */
public $jwtServerKey = null; public $serverKey = null;
/** If the user is valid, return the email in details /** 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); throw new \Exception ("No Bearer Authentication available", 401);
$token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7); $token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7);
$jwt = new jwt (); $jwt = new jwt ();
$payload = $jwt->decode ($token, $this->jwtServerKey); $payload = $jwt->decode ($token, $this->serverKey);
if (! key_exists ("email", $payload)) if (! key_exists ("email", $payload))
return null; return null;
// The JWT was tested in authparams. End of process // The JWT was tested in authparams. End of process