{"record":{"id":"498a19cbfec477d9","repo":"tymondesigns/jwt-auth","slug":"the-given-algorithm-could-not-be-found","errorCode":null,"errorMessage":"The given algorithm could not be found","messagePattern":"The given algorithm could not be found","errorType":"exception","errorClass":"Tymon\\JWTAuth\\Exceptions\\JWTException","httpStatus":null,"severity":"critical","filePath":"src/Providers/JWT/Lcobucci.php","lineNumber":199,"sourceCode":"\n        $config->setValidationConstraints(\n            new SignedWith($this->signer, $this->getVerificationKey())\n        );\n\n        return $config;\n    }\n\n    /**\n     * Get the signer instance.\n     *\n     * @return \\Lcobucci\\JWT\\Signer\n     *\n     * @throws \\Tymon\\JWTAuth\\Exceptions\\JWTException\n     */\n    protected function getSigner()\n    {\n        if (! array_key_exists($this->algo, $this->signers)) {\n            throw new JWTException('The given algorithm could not be found');\n        }\n\n        $signer = $this->signers[$this->algo];\n\n        if (is_subclass_of($signer, Ecdsa::class) && $this->usingV4()) {\n            return $signer::create();\n        }\n\n        return new $signer();\n    }\n\n    /**\n     * {@inheritdoc}\n     */\n    protected function isAsymmetric()\n    {\n        return is_subclass_of($this->signer, Rsa::class)\n            || is_subclass_of($this->signer, Ecdsa::class);","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/tymondesigns/jwt-auth/blob/6c70930a92710d97e8e52b182fca2176097f33be/src/Providers/JWT/Lcobucci.php#L181-L217","documentation":"Thrown by getSigner() when the configured algorithm string is not a key of the provider's supported signer map: HS256/HS384/HS512, RS256/RS384/RS512, ES256/ES384/ES512 (exact, case-sensitive). Because getSigner() runs in the provider constructor, this fires as soon as the JWT service is resolved from the container - typically on the first authenticated request, not at deploy time.","triggerScenarios":"Setting JWT_ALGO to anything outside the nine supported values: a typo (RS2156, HS254), a lowercase variant (hs256 - the array_key_exists lookup is case-sensitive), or a genuinely unsupported algorithm (PS256, EdDSA, RS1). Resolving auth('api'), JWTAuth facade, or any route behind auth:api middleware then throws JWTException immediately.","commonSituations":"Copy-pasting an algorithm name from another library's docs (e.g. node jsonwebtoken's PS256), an env value with trailing whitespace or quotes, upgrading from jwt-auth 0.5 where algorithm handling differed, or two apps sharing one .env with different expectations of JWT_ALGO.","solutions":["Set JWT_ALGO to one of the nine supported constants, e.g. JWT_ALGO=HS256 or RS256 - uppercase, no spaces","Check for typos, lowercase letters, and stray quotes/whitespace in the .env value: exact string match is required","Run php artisan config:clear after fixing .env so the cached config picks up the new value","If you need RSASSA-PSS or EdDSA, you cannot use this provider - keep the issuer on a supported algorithm or verify those tokens with a separate custom guard"],"exampleFix":"# before\nJWT_ALGO=hs256   # throws: The given algorithm could not be found\n\n# after\nJWT_ALGO=HS256","handlingStrategy":"validation","validationCode":"// Boot-time guard: fail fast at deploy, not on the first authenticated request\nuse Tymon\\JWTAuth\\Providers\\JWT\\Provider;\n\npublic function boot(): void\n{\n    $supported = [\n        Provider::ALGO_HS256, Provider::ALGO_HS384, Provider::ALGO_HS512,\n        Provider::ALGO_RS256, Provider::ALGO_RS384, Provider::ALGO_RS512,\n        Provider::ALGO_ES256, Provider::ALGO_ES384, Provider::ALGO_ES512,\n    ];\n    if (!in_array(config('jwt.algo'), $supported, true)) {\n        throw new RuntimeException('jwt.algo \"'.config('jwt.algo').'\" is not supported.');\n    }\n}","typeGuard":"function isSupportedJwtAlgo(?string $algo): bool\n{\n    return in_array($algo, [\n        'HS256', 'HS384', 'HS512',\n        'RS256', 'RS384', 'RS512',\n        'ES256', 'ES384', 'ES512',\n    ], true);\n}","tryCatchPattern":"use Tymon\\JWTAuth\\Exceptions\\JWTException;\n\ntry {\n    $token = JWTAuth::fromUser($user);\n} catch (JWTException $e) {\n    // constructor-time failure: algo/keys are misconfigured - surface as 500 config error\n    Log::critical('JWT provider misconfigured', ['error' => $e->getMessage()]);\n    abort(500, 'auth service is misconfigured');\n}","preventionTips":["Reference algorithm names via the Provider::ALGO_* constants in config/tests instead of raw strings","Add a config validation command to CI that asserts jwt.algo is one of the nine supported values","Re-run php artisan config:cache after any .env change; cached config keeps a bad value alive"],"tags":["jwt","php","laravel","algorithm","configuration","boot-error"],"backgroundTag":"jwt-unsupported-algorithm","analyzedSha":"6c70930a92710d97e8e52b182fca2176097f33be","analyzedAt":"2026-08-21T02:16:37.040Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}