Code Monkey home page Code Monkey logo

Comments (4)

weaverryan avatar weaverryan commented on August 25, 2024 1

Hey @emiliosa!

Hmm, I can see a few possible problems:

  1. public function checkCredentials needs to return true;. Without that, Guard will think that your authentication has failed

  2. Remove the public function createAuthenticatedToken method - this is implemented in a base class. By having this, but empty, it should break things.

  3. If you change these things, and it still doesn't work, let me know: it's quite possible that authentication IS successful, but your system is having problems reloading the user from the session. To know if this is a problem, you can change the intercept_redirects config to true temporarily (https://github.com/symfony/recipes/blob/fedaf4a81d15d182efa02733db5703bc35e4024d/symfony/web-profiler-bundle/3.3/config/packages/dev/web_profiler.yaml#L3). Then, after logging in with Google, the system will "stop" before redirecting you on success. On this "stopped" page, you will see the web debug toolbar. You can see if you are authenticated or anonymous. If you ARE authenticated... but then become anonymous after following the redirect, then you will know there is a problem reloading the user from the session (and I can help describe the solution).

Cheers!

from oauth2-client-bundle.

emiliosa avatar emiliosa commented on August 25, 2024

Hi, thanks for the quick reply, i was able to fix doing step 1 and 2, now i can login with any user vĂ­a google.

Thanks!

from oauth2-client-bundle.

diegogazzolo avatar diegogazzolo commented on August 25, 2024

Hi Ryan, I have this error:

" 3) If you change these things, and it still doesn't work, let me know: it's quite possible that authentication IS successful, but your system is having problems reloading the user from the session. To know if this is a problem, you can change the intercept_redirects config to true temporarily (https://github.com/symfony/recipes/blob/fedaf4a81d15d182efa02733db5703bc35e4024d/symfony/web-profiler-bundle/3.3/config/packages/dev/web_profiler.yaml#L3). Then, after logging in with Google, the system will "stop" before redirecting you on success. On this "stopped" page, you will see the web debug toolbar. You can see if you are authenticated or anonymous. If you ARE authenticated... but then become anonymous after following the redirect, then you will know there is a problem reloading the user from the session (and I can help describe the solution)."

Do you know tha cause? Thanks for your help.

from oauth2-client-bundle.

weaverryan avatar weaverryan commented on August 25, 2024

Hey @diegogazzolo!

Yes, I know this error VERY well :). For some reason, there is a problem deserializing your User object from the session.

First, if you have a serialize() method on your User object. Remove it. It could be the problem. Basically, at the beginning of each request, your User object is loaded from the session. Then, Symfony queries for a fresh User object from the database and compares the one from the session with the "fresh" User object. If they are "different", for security reasons, you are logged out. This can happen if you have a serialize() method on User and aren't serializing enough stuff. It can also easily happen if you're implementing the AdvancedUserInterface. Here is the logic Symfony uses to compare the users: https://github.com/symfony/symfony/blob/7135aa43380c26a38524a045b42414efb45cf48f/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php#L241

Let me know if that helps!

from oauth2-client-bundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.