1. Go to this page and download the library: Download wg-hyve/cloak-port library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
php
namespace My\Package;
use CloakPort\GuardContract;
use CloakPort\GuardTypeContract;
use CloakPort\TokenGuard as DefaultGuard;
use My\Package\TokenGuard as MyGuard;
enum GuardType implements GuardTypeContract
{
case KEYCLOAK;
case PASSPORT_CLIENT;
case PASSPORT_USER;
case MY_GUARD;
case DEFAULT;
public static function load(string $backend): self
{
return match(strtolower($backend)) {
'my_guard' => GuardType::MY_GUARD,
// ...
default => GuardType::DEFAULT
};
}
public function loadFrom(array $config): GuardContract
{
return match ($this) {
self::MY_GUARD => MyGuard::load($config),
// ...
self::DEFAULT => DefaultGuard::load($config)
};
}
}
php
namespace My\Package;
use CloakPort\GuardContract;
use CloakPort\TokenGuard as ParentTokenGuard;
use Illuminate\Contracts\Auth\Guard;
class TokenGuard extends ParentTokenGuard implements Guard, GuardContract
{
protected array $config = [];
public static function load(array $config): self
{
return new self();
}
public function setConfig(array $config): self
{
$this->config = $config;
return $this;
}
public function validate(array $credentials = [])
{
// any magic to valid your JWT
return $this->check();
}
public function check()
{
return false;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.