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