authjwt : gettext exceptions errors
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5817 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
22
authjwt.php
22
authjwt.php
@@ -64,9 +64,11 @@ class authjwt extends auth
|
|||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
if (! isset ($_SERVER["HTTP_AUTHENTICATION"]))
|
if (! isset ($_SERVER["HTTP_AUTHENTICATION"]))
|
||||||
throw new \Exception ("No Authentication available", 401);
|
throw new \Exception (dgettext ("domframework",
|
||||||
|
"No Authentication available"), 401);
|
||||||
if (substr ($_SERVER["HTTP_AUTHENTICATION"], 0, 7) !== "Bearer ")
|
if (substr ($_SERVER["HTTP_AUTHENTICATION"], 0, 7) !== "Bearer ")
|
||||||
throw new \Exception ("No Bearer Authentication available", 401);
|
throw new \Exception (dgettext ("domframework",
|
||||||
|
"No Bearer Authentication available"), 401);
|
||||||
$token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7);
|
$token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7);
|
||||||
$jwt = new jwt ();
|
$jwt = new jwt ();
|
||||||
$uuid = $jwt->decode ($token, $this->serverKey, $this->allowedAlg,
|
$uuid = $jwt->decode ($token, $this->serverKey, $this->allowedAlg,
|
||||||
@@ -111,10 +113,11 @@ class authjwt extends auth
|
|||||||
if ($this->serverKey === null)
|
if ($this->serverKey === null)
|
||||||
return "";
|
return "";
|
||||||
if (! key_exists ("email", $auth))
|
if (! key_exists ("email", $auth))
|
||||||
throw new \Exception ("AuthJWT : No email available in auth", 403);
|
throw new \Exception (dgettext ("domframework",
|
||||||
|
"AuthJWT : No email available in auth"), 403);
|
||||||
if ($auth["email"] === "anonymous")
|
if ($auth["email"] === "anonymous")
|
||||||
throw new \Exception ("AuthJWT : can not create token for anonymous",
|
throw new \Exception (dgettext ("domframework",
|
||||||
403);
|
"AuthJWT : can not create token for anonymous"), 403);
|
||||||
$uuid = uuid::uuid4 ();
|
$uuid = uuid::uuid4 ();
|
||||||
$cachefile = new cachefile ();
|
$cachefile = new cachefile ();
|
||||||
$cachefile->directory = $this->cacheDir;
|
$cachefile->directory = $this->cacheDir;
|
||||||
@@ -158,9 +161,11 @@ class authjwt extends auth
|
|||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
if (! isset ($_SERVER["HTTP_AUTHENTICATION"]))
|
if (! isset ($_SERVER["HTTP_AUTHENTICATION"]))
|
||||||
throw new \Exception ("No Authentication available", 401);
|
throw new \Exception (dgettext ("domframework",
|
||||||
|
"No Authentication available"), 401);
|
||||||
if (substr ($_SERVER["HTTP_AUTHENTICATION"], 0, 7) !== "Bearer ")
|
if (substr ($_SERVER["HTTP_AUTHENTICATION"], 0, 7) !== "Bearer ")
|
||||||
throw new \Exception ("No Bearer Authentication available", 401);
|
throw new \Exception (dgettext ("domframework",
|
||||||
|
"No Bearer Authentication available"), 401);
|
||||||
$token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7);
|
$token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7);
|
||||||
$jwt = new jwt ();
|
$jwt = new jwt ();
|
||||||
$uuid = $jwt->decode ($token, $this->serverKey, $this->allowedAlg,
|
$uuid = $jwt->decode ($token, $this->serverKey, $this->allowedAlg,
|
||||||
@@ -169,7 +174,8 @@ class authjwt extends auth
|
|||||||
$cachefile->directory = $this->cacheDir;
|
$cachefile->directory = $this->cacheDir;
|
||||||
$payload = $cachefile->read ((string)$uuid);
|
$payload = $cachefile->read ((string)$uuid);
|
||||||
if (empty ($uuid) || empty ($payload) || ! key_exists ("email", $payload))
|
if (empty ($uuid) || empty ($payload) || ! key_exists ("email", $payload))
|
||||||
throw new \Exception ("Can not found the token : no logout", 403);
|
throw new \Exception (dgettext ("domframework",
|
||||||
|
"Can not found the token : no logout"), 403);
|
||||||
$cachefile->delete ($uuid);
|
$cachefile->delete ($uuid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user