symfony/symfony · error · LogicException

Unable to find an authenticator named "%s" for the firewall

Error message

Unable to find an authenticator named "%s" for the firewall "%s". Available authenticators: "%s".

What it means

Thrown by `Security::getAuthenticator()` when an `$authenticatorName` was passed but it matches neither a service in the firewall's authenticator locator directly nor the prefixed `security.authenticator.<name>.<firewall>` id. The exception lists all authenticators actually registered for that firewall to guide the fix.

Source

Thrown at src/Symfony/Bundle/SecurityBundle/Security.php:262

            $authenticatorIds = array_filter(array_keys($firewallAuthenticatorLocator->getProvidedServices()), static fn (string $authenticatorId) => $authenticatorId !== \sprintf('security.authenticator.remember_me.%s', $firewallName));
            if (!$authenticatorIds) {
                throw new LogicException(\sprintf('No authenticator was found for the firewall "%s".', $firewallName));
            }
            if (1 < \count($authenticatorIds)) {
                throw new LogicException(\sprintf('Too many authenticators were found for the current firewall "%s". You must provide an instance of "%s" to login programmatically. The available authenticators for the firewall "%s" are "%s".', $firewallName, AuthenticatorInterface::class, $firewallName, implode('" ,"', $authenticatorIds)));
            }

            return $firewallAuthenticatorLocator->get($authenticatorIds[0]);
        }

        if ($firewallAuthenticatorLocator->has($authenticatorName)) {
            return $firewallAuthenticatorLocator->get($authenticatorName);
        }

        $authenticatorId = 'security.authenticator.'.$authenticatorName.'.'.$firewallName;

        if (!$firewallAuthenticatorLocator->has($authenticatorId)) {
            throw new LogicException(\sprintf('Unable to find an authenticator named "%s" for the firewall "%s". Available authenticators: "%s".', $authenticatorName, $firewallName, implode('", "', array_keys($firewallAuthenticatorLocator->getProvidedServices()))));
        }

        return $firewallAuthenticatorLocator->get($authenticatorId);
    }
}

View on GitHub (pinned to 698e28026c)

Solutions

  1. Read the exception's "Available authenticators" list and pass one of those exact names.
  2. Use the authenticator's service id / class FQCN if that's how it's registered: `$security->login($user, App\Security\ApiKeyAuthenticator::class);`.
  3. Make sure the authenticator is actually registered on the target firewall (tagged/configured under it).

Example fix

// before
$security->login($user, 'api_key');
// after
$security->login($user, App\Security\ApiKeyAuthenticator::class);
Defensive patterns

Strategy: validation

Validate before calling

// Validate the authenticator name against registered ones before login:
$available = $container->get('security.authenticators.manifest') ?? []; // project-specific source
if (!in_array($authenticatorName, $available, true)) {
    throw new \InvalidArgumentException(sprintf('Unknown authenticator "%s".', $authenticatorName));
}
$security->login($user, $authenticatorName, $firewallName);

Try / catch

try {
    $security->login($user, $authenticatorName, $firewallName);
} catch (\Symfony\Component\Security\Core\Exception\LogicException $e) {
    if (preg_match('/Available authenticators: "(.+)"/', $e->getMessage(), $m)) {
        $first = explode('", "', $m[1])[0];
        $security->login($user, $first, $firewallName);
    } else { throw $e; }
}

Prevention

When it happens

Trigger: Calling `$security->login($user, 'api_key')` when no authenticator named `api_key` exists for the firewall. Line 255-263 first tries the raw name, then the prefixed id, then throws.

Common situations: Passing the authenticator's PHP class name when it's registered under a different short name, or vice versa. Renaming an authenticator service without updating the `login()` call. Typo in the authenticator name.

Understand the failure class

Related errors


AI-assisted analysis of symfony/symfony@698e28026c (2026-08-06). Data as JSON: /api/errors/0f0cd366495938af. Report an issue: GitHub.