A free open source IT asset/license management system
Resolve the last two static analysis findings properly
Rod Christiansenfa90c59b5ec5
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.phpindex 981e21ff5a..24ab13ad1e 100644--- a/app/Providers/AuthServiceProvider.php+++ b/app/Providers/AuthServiceProvider.php@@ -87,6 +87,8 @@ class AuthServiceProvider extends ServiceProvider* Register any authentication / authorization services.** @return void+ *+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)*/public function boot(){@@ -109,7 +111,6 @@ class AuthServiceProvider extends ServiceProvider// config('oidc.enabled') is true, so this is purely additive.// `$name` is unused: Laravel fixes the driver-closure signature as// ($app, $name, $config), and the guard is named by config/auth.php.- /** @SuppressWarnings(PHPMD.UnusedFormalParameter) */Auth::extend('oidc', function ($app, $name, array $config) {return new \App\Auth\OidcGuard(Auth::createUserProvider($config['provider']),diff --git a/tests/Feature/Authentication/OidcApiAuthTest.php b/tests/Feature/Authentication/OidcApiAuthTest.phpindex e5173c8f17..66255b5413 100644--- a/tests/Feature/Authentication/OidcApiAuthTest.php+++ b/tests/Feature/Authentication/OidcApiAuthTest.php@@ -8,6 +8,7 @@ use Firebase\JWT\JWT;use Firebase\JWT\Key;use Illuminate\Support\Facades\Route;use Laravel\Passport\Passport;+use PHPUnit\Framework\Assert;use Tests\TestCase;/**@@ -57,23 +58,28 @@ class OidcApiAuthTest extends TestCase// Stub JWKS retrieval with the local public key so the validator never// hits the network; iss/aud/exp/signature validation still run for real.- $this->app->instance(OidcTokenValidator::class, new class($publicPem, $this->kid) extends OidcTokenValidator+ $this->app->instance(OidcTokenValidator::class, new class($publicPem, $this->kid, $this->issuer) extends OidcTokenValidator{private string $pub;private string $signingKid;- public function __construct(string $pub, string $signingKid)+ private string $expectedIssuer;++ public function __construct(string $pub, string $signingKid, string $expectedIssuer){$this->pub = $pub;$this->signingKid = $signingKid;+ $this->expectedIssuer = $expectedIssuer;}- /**- * @SuppressWarnings(PHPMD.UnusedFormalParameter)- */protected function signingKeys(string $issuer): array{+ // Keys are only ever served for the issuer the validator already+ // matched against the trusted list -- asserting it here means an+ // untrusted issuer can never reach key resolution unnoticed.+ Assert::assertSame($this->expectedIssuer, $issuer);+return [$this->signingKid => new Key($this->pub, 'RS256')];}});