Git Product home page Git Product logo

Comments (9)

kayue avatar kayue commented on July 30, 2024

@Louis94 This is possible, but a bit difficult to config. Any only tested with WordPress 3.

You have to config the following in config.yml

    # The following configuration only needed only when you use WordPress authentication. 

    # Site URL must match *EXACTLY* with WordPress's setting. Can be found
    # on the Settings > General screen, there are field named "WordPress Address"
    site_url:       'http://localhost/wordpress'

    # Logged in key and salt. Can be found in the wp-config.php file.
    logged_in_key:  ':j$_=(:l@8Fku^U;MQ~#VOJXOZcVB_@u+t-NNYqmTH4na|)5Bhs1|tF1IA|>tz*E'
    logged_in_salt: ')A^CQ<R:1|^dK/Q;.QfP;U!=J=(_i6^s0f#2EIbGIgFN{,3U9H$q|o/sJfWF`NRM'

And then config security.yml, see https://github.com/kayue/KayueWordpressBundle/blob/master/README.md#wordpress-authentication

In monolog it will show why it failed to login.

from kayuewordpressbundle.

kayue avatar kayue commented on July 30, 2024

The source code is here: https://github.com/kayue/KayueWordpressBundle/blob/master/Security/Http/WordpressCookieService.php#L61-L90

Few common reason why failed:

  • Site url doesn't match with WordPress. It must match with WordPress's settings in order to retrieve the correct cookie name, otherwise you will see cookie not detected.
  • logged_in_key and logged_in_salt must match. It is required to verify the cookie content.

from kayuewordpressbundle.

Louis94 avatar Louis94 commented on July 30, 2024

Thank you very much for you answer!
I was able to get it work with wordpress 3! (Didn't work out with wordpress 4, was just able to authenticate but not share the login session)

I noticed that the logout doesn't work as I expected to.
From what I was able to see, it just redirect me to the login page, but the cookie session is still alive and if I try to access directly the secured area, it let me. (Also, i'm still logged in on wordpress)

So, what I wanted to ask you,
is there a way to log out in wordpress by logging out in symfony?
(I noticed the WordpressCookieClearkingLogoutHandler, so I guess that there's should be a way, but I don't understand when is it called. By the way, i have setup everything on the Acme Demo Bundle, so no customized bundle)

from kayuewordpressbundle.

kayue avatar kayue commented on July 30, 2024

It should be called when you logout in Symfony. (If you logout in WordPress, it won't reflect in Symfony, because Symfony rely on session instead of cookie)

Can you check is WordpressCookieClearingLogoutHandler being called when logout? It suppose delete some cookie.

from kayuewordpressbundle.

Louis94 avatar Louis94 commented on July 30, 2024

I don't think so.
In the log i can see that it call the logoutAction, it then read the SecurityContext from the session and reload the user from the user provider.
Following that, is a query that it probably select the same user again and it continue by saying that the username "luigi" was reloaded from user provider

Here the log: (part of it of course)
[2015-02-25 14:06:25] request.INFO: Matched route "_demo_logout" (parameters: "_controller": "Acme\DemoBundle\Controller\SecuredController::logoutAction", "_route": "_demo_logout") [] []
[2015-02-25 14:06:25] security.DEBUG: Read SecurityContext from the session [] []
[2015-02-25 14:06:25] security.DEBUG: Reloading user from user provider. [] []
[2015-02-25 14:06:25] doctrine.DEBUG: SELECT t0.ID AS ID1, t0.user_login AS user_login2, t0.user_pass AS user_pass3, t0.user_nicename AS user_nicename4, t0.user_email AS user_email5, t0.user_url AS user_url6, t0.user_registered AS user_registered7, t0.user_activation_key AS user_activation_key8, t0.user_status AS user_status9, t0.display_name AS display_name10 FROM wp3_users t0 WHERE t0.ID = ? ["1"] []
[2015-02-25 14:06:25] security.DEBUG: Username "luigi" was reloaded from user provider. [] []

from kayuewordpressbundle.

Louis94 avatar Louis94 commented on July 30, 2024

I have just checked the case when you logout from wordpress, and it seems that it actually also log you out from symfony as well.
Not sure if it is as you intended.

from kayuewordpressbundle.

kayue avatar kayue commented on July 30, 2024

@Louis94 Oh you are right. In the following line it will check for WordPress cookie on every request. I forgot I did it already.

https://github.com/kayue/KayueWordpressBundle/blob/master/Security/Firewall/WordpressListener.php#L73

I am not sure why logout handler isn't being triggered. I think you can try to debug the following files..

from kayuewordpressbundle.

Louis94 avatar Louis94 commented on July 30, 2024

Fixed everything!
It was something in my config file that I wrongly configured (I configured cookie_domain to localhost instead of null).
It now work perfectly!
Thank you for your time!

from kayuewordpressbundle.

kayue avatar kayue commented on July 30, 2024

👍

from kayuewordpressbundle.

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.