Skip to content

Method triggerRememberMe not called because of LazyResponseException #34761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lukepass opened this issue Dec 2, 2019 · 3 comments
Closed

Method triggerRememberMe not called because of LazyResponseException #34761

lukepass opened this issue Dec 2, 2019 · 3 comments

Comments

@lukepass
Copy link

lukepass commented Dec 2, 2019

Symfony version(s) affected: 4.4.0

Description
I am developing a site using Symfony 4 and I noticed that remember me functionality is not working (the cookie is not set at all). I followed this tutorial:

https://symfony.com/doc/4.4/security/remember_me.html

Please see this post for all my configuration settings:

https://stackoverflow.com/questions/59086076/symfony-4-remember-me-cookie-not-set?noredirect=1#comment104435173_59086076

Essentially the remember me is not triggered at all:

// success!
$response = $this->guardHandler->handleAuthenticationSuccess($token, $request, $guardAuthenticator, $this->providerKey);
if ($response instanceof Response) {
    if (null !== $this->logger) {
        $this->logger->debug('Guard authenticator set success response.', ['response' => $response, 'authenticator' => \get_class($guardAuthenticator)]);
    }

    $event->setResponse($response); // <-- this is where the esecution STOPs
} else {
    if (null !== $this->logger) {
        $this->logger->debug('Guard authenticator set no success response: request continues.', ['authenticator' => \get_class($guardAuthenticator)]);
    }
}

// --> This line is NEVER CALLED
// attempt to trigger the remember me functionality
$this->triggerRememberMe($guardAuthenticator, $request, $token, $response);
// <-- This line is NEVER CALLED

Debugging into setResponse I saw that it's throwing a LazyResponseException and so the next line is never reached.

How to reproduce
Follow the remember me tutorial and set up a GuardAuthenticationListener.

Possible Solution
Maybe the triggerRememberMe should be called earlier?

Additional context
Please review the following StackOverflow post where you can find all the relevant classes and configurations:

https://stackoverflow.com/questions/59086076/symfony-4-remember-me-cookie-not-set?noredirect=1#comment104435173_59086076

Thanks.

@lukepass
Copy link
Author

lukepass commented Dec 2, 2019

A quick update, it seems that executing composer update resolved the issue:

composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.4.*"

Prefetching 45 packages 🎶 💨
  - Downloading (100%)

Package operations: 0 installs, 62 updates, 0 removals
  - Updating symfony/flex (v1.4.8 => v1.5.3): Loading from cache
  - Updating symfony/dotenv (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/service-contracts (v2.0.0 => v2.0.1): Loading from cache
  - Updating symfony/var-exporter (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/cache-contracts (v2.0.0 => v2.0.1): Loading from cache
  - Updating symfony/cache (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/expression-language (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/inflector (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/property-access (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/polyfill-mbstring (v1.12.0 => v1.13.1): Loading from cache
  - Updating symfony/options-resolver (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/intl (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/polyfill-intl-icu (v1.12.0 => v1.13.1): Loading from cache
  - Updating symfony/event-dispatcher (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/form (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/polyfill-php72 (v1.12.0 => v1.13.1): Loading from cache
  - Updating symfony/var-dumper (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/debug (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/error-handler (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/polyfill-php73 (v1.12.0 => v1.13.1): Loading from cache
  - Updating symfony/http-client-contracts (v2.0.0 => v2.0.1): Loading from cache
  - Updating symfony/http-client (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/polyfill-intl-idn (v1.12.0 => v1.13.1): Loading from cache
  - Updating symfony/mime (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/mailer (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/http-foundation (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/http-kernel (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/monolog-bridge (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/process (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/security-core (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/security-http (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/security-guard (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/security-csrf (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/dependency-injection (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/filesystem (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/config (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/security-bundle (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/translation-contracts (v2.0.0 => v2.0.1): Loading from cache
  - Updating symfony/translation (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/validator (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/web-link (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/asset (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/webpack-encore-bundle (v1.7.1 => v1.7.2): Loading from cache
  - Updating symfony/yaml (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/phpunit-bridge (v5.0.0 => v5.0.1): Loading from cache
  - Updating symfony/finder (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/routing (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/framework-bundle (v4.4.0 => v4.4.1): Loading from cache
  - Updating doctrine/cache (1.9.1 => 1.10.0): Loading from cache
  - Updating symfony/doctrine-bridge (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/console (v4.4.0 => v4.4.1): Loading from cache
  - Updating doctrine/doctrine-bundle (2.0.0 => 2.0.2): Loading from cache
  - Updating symfony/twig-bridge (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/debug-bundle (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/stopwatch (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/twig-bundle (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/web-profiler-bundle (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/property-info (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/serializer (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/dom-crawler (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/browser-kit (v4.4.0 => v4.4.1): Loading from cache
  - Updating symfony/css-selector (v4.4.0 => v4.4.1): Loading from cache
Writing lock file
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class

What about running composer global require symfony/thanks && composer thanks now?
This will spread some 💖  by sending a ★  to the GitHub repositories of your fellow package maintainers.

Executing script cache:clear [OK]
Executing script assets:install public [OK]

Do you know why?

@chalasr
Copy link
Member

chalasr commented Dec 2, 2019

Probably fixed by #34627 which is part of the 4.4.1 release

@lukepass
Copy link
Author

lukepass commented Dec 2, 2019

Do you know what was causing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants