You've already forked Php-Template
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 2m50s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 2m41s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 3m8s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 3m22s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 3m5s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m41s
Reviewed-on: #11 Co-authored-by: Ron Rise <ron@siteworxpro.com> Co-committed-by: Ron Rise <ron@siteworxpro.com>
44 lines
874 B
PHP
44 lines
874 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Siteworxpro\App\Annotations\Guards;
|
|
|
|
use Attribute;
|
|
use Siteworxpro\App\Services\Facades\Config;
|
|
|
|
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
|
|
readonly class Jwt
|
|
{
|
|
public function __construct(
|
|
private string $issuer = '',
|
|
private string $audience = '',
|
|
) {
|
|
}
|
|
|
|
public function getRequiredAudience(): string
|
|
{
|
|
return Config::get('jwt.audience') ?? '';
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getAudience(): string
|
|
{
|
|
if ($this->audience === '') {
|
|
return Config::get('jwt.audience') ?? '';
|
|
}
|
|
|
|
return $this->audience;
|
|
}
|
|
|
|
public function getIssuer(): string
|
|
{
|
|
if ($this->issuer === '') {
|
|
return Config::get('jwt.issuer') ?? '';
|
|
}
|
|
|
|
return $this->issuer;
|
|
}
|
|
} |