Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Drupal\rest_api_authentication; use Drupal\user\Entity\User; use ..
Decoded Output download
<?php
namespace Drupal\rest_api_authentication;
use Drupal\user\Entity\User;
use Drupal\rest_api_authentication\Utilities;
use Drupal\Component\Utility\Html;
use Drupal\rest_api_authentication\DBQueries;
class API_Authentication_Ext_OAuth
{
static function validate_api_request($BB)
{
$DT = array();
$DT["status"] = "error";
$kl = '';
if (!(!empty(\Drupal::config("rest_api_authentication.settings")->get("custom_header")) || \Drupal::config("rest_api_authentication.settings")->get("custom_header") != null)) {
goto ip;
}
$P9 = $BB->headers->get(\Drupal::config("rest_api_authentication.settings")->get("custom_header"));
ip:
if (!($BB->headers->get("TOKEN") != null)) {
goto WT;
}
$P9 = $BB->headers->get("TOKEN") != null ? $BB->headers->get("TOKEN") : null;
WT:
$P9 = Html::escape(urldecode($P9));
if ($P9 != null) {
goto mF;
}
$DT["status"] = "ERROR";
$DT["http_code"] = "401";
$DT["error"] = "INVALID_TOKEN";
$DT["message"] = "Invalid request: Token Not Found.";
goto Yq;
mF:
$Rq = \Drupal::config("rest_api_authentication.settings")->get("user_info_endpoint") != null ? \Drupal::config("rest_api_authentication.settings")->get("user_info_endpoint") : null;
if (!(empty($Rq) || is_null($Rq))) {
goto bE;
}
$DT["status"] = "ERROR";
$DT["http_code"] = "404";
$DT["error"] = "INVALID_USER_INFO_ENDPOINT";
$DT["message"] = "Could not authenticate the token from your Provider. Please check your configurations.";
return $DT;
bE:
$Ld = \Drupal::config("rest_api_authentication.settings")->get("username_attribute") != null ? \Drupal::config("rest_api_authentication.settings")->get("username_attribute") : null;
$im = Utilities::getResourceOwner($Rq, $P9);
if (empty($im)) {
goto uk;
}
$JY = Utilities::getnestedattribute($im, $Ld);
uk:
if (!empty($JY)) {
goto Au;
}
$DT["status"] = "ERROR";
$DT["http_code"] = "401";
$DT["error"] = "INVALID_USERNAME_ATTRIBUTE";
$DT["message"] = "Invalid request: Could not get user information.";
return $DT;
Au:
$user = user_load_by_name($JY);
$t8 = \Drupal::config("rest_api_authentication.settings")->get("ex_oauth_create_new_user");
if (!(!$user && !$t8)) {
goto Br;
}
$DT["status"] = "error";
$DT["http_code"] = "401";
$DT["error"] = "USER_NOT_FOUND";
$DT["message"] = "User Not Found in Drupal.";
return $DT;
Br:
if (!(empty($user) && $t8)) {
goto ax;
}
$Vp = \Drupal::service("password_generator")->generate(8);
$ul = array("name" => $JY, "mail" => $JY, "pass" => $Vp, "status" => 1, "roles" => array());
$user = User::create($ul);
$user->save();
ax:
$DT["status"] = "SUCCESS";
$DT["user"] = $user;
Yq:
return $DT;
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Drupal\rest_api_authentication;
use Drupal\user\Entity\User;
use Drupal\rest_api_authentication\Utilities;
use Drupal\Component\Utility\Html;
use Drupal\rest_api_authentication\DBQueries;
class API_Authentication_Ext_OAuth
{
static function validate_api_request($BB)
{
$DT = array();
$DT["\x73\164\141\164\165\x73"] = "\x65\x72\162\157\x72";
$kl = '';
if (!(!empty(\Drupal::config("\162\145\163\x74\137\x61\160\x69\x5f\141\x75\164\x68\145\x6e\164\151\x63\141\x74\151\x6f\156\56\163\x65\164\164\x69\x6e\x67\163")->get("\143\x75\x73\x74\x6f\x6d\x5f\x68\x65\x61\144\x65\x72")) || \Drupal::config("\x72\145\x73\x74\137\x61\x70\x69\x5f\141\x75\x74\x68\145\156\x74\151\143\141\164\151\x6f\156\56\163\x65\164\x74\151\x6e\x67\163")->get("\143\165\163\164\157\155\x5f\150\x65\x61\144\x65\162") != null)) {
goto ip;
}
$P9 = $BB->headers->get(\Drupal::config("\x72\145\x73\164\x5f\141\160\151\137\x61\165\x74\x68\145\x6e\164\x69\x63\141\x74\x69\x6f\156\x2e\x73\x65\x74\164\x69\x6e\x67\x73")->get("\143\x75\x73\x74\x6f\155\x5f\x68\145\141\144\x65\162"));
ip:
if (!($BB->headers->get("\124\x4f\x4b\105\x4e") != null)) {
goto WT;
}
$P9 = $BB->headers->get("\x54\x4f\x4b\105\116") != null ? $BB->headers->get("\124\x4f\x4b\x45\116") : null;
WT:
$P9 = Html::escape(urldecode($P9));
if ($P9 != null) {
goto mF;
}
$DT["\x73\164\141\164\165\x73"] = "\105\x52\x52\x4f\x52";
$DT["\150\x74\x74\x70\137\x63\157\144\145"] = "\x34\x30\x31";
$DT["\x65\162\162\x6f\162"] = "\111\x4e\x56\101\x4c\111\x44\137\x54\x4f\x4b\105\x4e";
$DT["\155\145\163\163\141\147\145"] = "\x49\156\166\x61\x6c\151\x64\40\x72\145\x71\165\x65\x73\x74\x3a\x20\124\157\153\x65\x6e\x20\116\x6f\x74\x20\x46\157\x75\x6e\144\56";
goto Yq;
mF:
$Rq = \Drupal::config("\162\145\163\164\x5f\141\x70\x69\x5f\x61\x75\164\150\145\x6e\x74\151\x63\x61\164\151\x6f\156\x2e\163\145\164\164\151\x6e\x67\x73")->get("\165\163\x65\x72\x5f\151\156\x66\x6f\x5f\145\x6e\144\160\x6f\x69\156\x74") != null ? \Drupal::config("\x72\145\163\164\137\x61\160\x69\137\x61\x75\x74\150\x65\156\x74\151\143\141\164\151\x6f\156\56\x73\145\x74\x74\151\156\x67\163")->get("\165\x73\145\x72\x5f\151\156\146\157\x5f\145\156\x64\160\157\151\x6e\x74") : null;
if (!(empty($Rq) || is_null($Rq))) {
goto bE;
}
$DT["\x73\164\141\x74\x75\163"] = "\105\122\x52\x4f\x52";
$DT["\150\x74\x74\160\x5f\143\157\144\x65"] = "\x34\x30\x34";
$DT["\145\162\162\157\x72"] = "\111\x4e\126\x41\x4c\x49\104\x5f\125\123\x45\122\x5f\x49\x4e\x46\x4f\137\105\x4e\104\x50\117\x49\116\x54";
$DT["\x6d\x65\163\x73\141\x67\x65"] = "\x43\157\x75\154\144\40\x6e\157\x74\40\x61\x75\x74\x68\145\x6e\x74\x69\x63\141\164\x65\40\164\x68\x65\40\164\x6f\153\x65\156\40\x66\x72\157\x6d\x20\x79\x6f\x75\x72\x20\x50\x72\x6f\x76\x69\144\145\x72\56\x20\120\x6c\x65\141\x73\145\x20\x63\150\x65\143\153\x20\x79\157\x75\162\x20\x63\x6f\156\146\151\147\x75\x72\141\x74\x69\157\x6e\163\56";
return $DT;
bE:
$Ld = \Drupal::config("\x72\x65\x73\x74\x5f\x61\160\x69\137\x61\x75\164\x68\x65\156\x74\x69\x63\x61\x74\x69\x6f\x6e\x2e\x73\x65\x74\x74\151\x6e\x67\x73")->get("\x75\x73\x65\x72\156\x61\155\x65\137\x61\x74\164\162\151\x62\x75\164\145") != null ? \Drupal::config("\162\145\163\x74\137\141\x70\151\137\141\165\164\150\x65\156\x74\151\143\x61\x74\151\x6f\156\56\x73\145\164\164\x69\156\147\163")->get("\x75\x73\x65\162\156\141\x6d\x65\x5f\x61\x74\164\x72\x69\x62\x75\x74\145") : null;
$im = Utilities::getResourceOwner($Rq, $P9);
if (empty($im)) {
goto uk;
}
$JY = Utilities::getnestedattribute($im, $Ld);
uk:
if (!empty($JY)) {
goto Au;
}
$DT["\163\164\x61\164\165\163"] = "\x45\x52\x52\117\x52";
$DT["\x68\164\x74\x70\137\143\x6f\144\145"] = "\x34\60\x31";
$DT["\x65\162\162\x6f\x72"] = "\111\x4e\126\x41\114\x49\x44\137\125\123\x45\122\x4e\101\x4d\x45\137\x41\x54\x54\122\111\x42\125\124\105";
$DT["\x6d\145\x73\x73\x61\x67\145"] = "\x49\156\166\141\x6c\x69\144\x20\162\145\161\x75\x65\163\x74\72\x20\103\157\165\154\x64\x20\156\x6f\164\x20\x67\145\164\40\165\x73\x65\162\x20\151\x6e\146\157\x72\x6d\141\164\151\157\x6e\56";
return $DT;
Au:
$user = user_load_by_name($JY);
$t8 = \Drupal::config("\162\x65\163\x74\137\x61\x70\x69\137\x61\165\x74\x68\x65\156\x74\x69\143\141\164\x69\x6f\x6e\56\163\145\x74\x74\151\x6e\147\163")->get("\145\x78\x5f\x6f\x61\165\x74\x68\x5f\x63\x72\x65\141\x74\145\137\156\145\167\137\165\x73\145\162");
if (!(!$user && !$t8)) {
goto Br;
}
$DT["\163\164\141\x74\x75\163"] = "\x65\162\162\157\x72";
$DT["\150\x74\164\x70\x5f\143\x6f\x64\x65"] = "\x34\60\61";
$DT["\x65\x72\x72\x6f\162"] = "\125\123\105\122\x5f\x4e\x4f\124\x5f\106\x4f\125\x4e\x44";
$DT["\155\145\163\163\x61\147\145"] = "\x55\163\x65\162\x20\116\157\x74\x20\x46\157\165\x6e\144\40\x69\156\x20\x44\x72\x75\160\141\154\x2e";
return $DT;
Br:
if (!(empty($user) && $t8)) {
goto ax;
}
$Vp = \Drupal::service("\160\x61\163\163\167\x6f\162\x64\x5f\147\145\x6e\x65\x72\x61\x74\157\x72")->generate(8);
$ul = array("\x6e\141\x6d\145" => $JY, "\155\x61\151\154" => $JY, "\160\x61\x73\x73" => $Vp, "\x73\164\x61\164\165\163" => 1, "\162\x6f\154\145\x73" => array());
$user = User::create($ul);
$user->save();
ax:
$DT["\163\x74\x61\x74\x75\163"] = "\x53\125\x43\x43\105\x53\123";
$DT["\x75\x73\x65\x72"] = $user;
Yq:
return $DT;
}
}
Function Calls
None |
Stats
MD5 | 28b1e82ff789d859973d40f8d992249f |
Eval Count | 0 |
Decode Time | 60 ms |