chore: add deployment configurations and tests for logger and dispatcher (#18)
All checks were successful
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m54s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m48s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 3m9s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 3m9s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 3m4s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 2m44s

Reviewed-on: #18
Co-authored-by: Ron Rise <ron@siteworxpro.com>
Co-committed-by: Ron Rise <ron@siteworxpro.com>
This commit was merged in pull request #18.
This commit is contained in:
2025-11-14 18:04:49 +00:00
committed by Siteworx Pro Gitea
parent 7fe2722fc1
commit 474134c654
15 changed files with 132 additions and 22 deletions

View File

@@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
namespace Siteworxpro\App\Attributes\Guards;
use Attribute;
use Siteworxpro\App\Services\Facades\Config;
/**
* Attribute to guard classes or methods with JWT claim requirements.
*
* Apply this attribute to a class or method to declare the expected JWT issuer and/or audience.
* If either the issuer or audience is an empty string, the value will be resolved from configuration:
* - `jwt.issuer`
* - `jwt.audience`
*
* Targets: class or method.
*/
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
readonly class Jwt
{
/**
* Initialize the Jwt attribute with optional overrides for expected JWT claims.
*
* @param string $issuer Optional expected JWT issuer (`iss`). Empty string uses `Config::get('jwt.issuer')`.
* @param string $audience Optional expected JWT audience (`aud`). Empty string uses `Config::get('jwt.audience')`.
*/
public function __construct(
private string $issuer = '',
private string $audience = '',
) {
}
/**
* Get the expected audience for validation.
*
* Returns the constructor-provided audience when non-empty; otherwise falls back to `jwt.audience` config.
*
* @return string The audience value to enforce.
*/
public function getAudience(): string
{
if ($this->audience === '') {
return Config::get('jwt.audience') ?? '';
}
return $this->audience;
}
/**
* Get the expected issuer for validation.
*
* Returns the constructor-provided issuer when non-empty; otherwise falls back to `jwt.issuer` config.
*
* @return string The issuer value to enforce.
*/
public function getIssuer(): string
{
if ($this->issuer === '') {
return Config::get('jwt.issuer') ?? '';
}
return $this->issuer;
}
}