Comments (9)
@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.
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
andlogged_in_salt
must match. It is required to verify the cookie content.
from kayuewordpressbundle.
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.
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.
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.
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.
@Louis94 Oh you are right. In the following line it will check for WordPress cookie on every request. I forgot I did it already.
I am not sure why logout handler isn't being triggered. I think you can try to debug the following files..
- Logout handler is registered at:
- The actual method that remove the WordPress cookie: https://github.com/kayue/KayueWordpressBundle/blob/master/Wordpress/AuthenticationCookieManager.php#L130-L141
from kayuewordpressbundle.
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.
👍
from kayuewordpressbundle.
Related Issues (20)
- Difficulty linking directly to post HOT 3
- Cannot persist Comment or Post entities HOT 1
- When doctrine:generate:entities - Error on TablePrefixSubscriber.php : getClassAnnotations() must be an instance of ReflectionClass HOT 6
- Incompatibility with doctrine fixtures HOT 9
- Stable release with entity manager support HOT 3
- Attempted to call method "setBlogId" on class "Doctrine\ORM\EntityManager" in vendor/kayue/kayue-wordpress-bundle/Kayue/WordpressBundle/Model/BlogManager.php line 62. HOT 4
- Attachment->getUrl is broken
- [RFC] Gallery shortcode HOT 8
- Tag a new version HOT 2
- How to use this an FOSUserBundle for login HOT 2
- A Token was not found in the SecurityContext. HOT 1
- Fix 3.x Deprecation warnings before 3.x release
- Missing Service HOT 6
- Override the User type so I can implement an interface
- securety.yml HOT 3
- Composer problems with versions
- Post Thumbnail HOT 4
- Cannot autowire: The class 'Kayue\WordpressBundle\Entity\Post' was not found in the chain configured namespaces App\Entity HOT 1
- Error with Symfony 4.4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kayuewordpressbundle.