Skip to content
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

Users in other sites but not main site will not have any roles #22

Closed
luiges90 opened this issue Sep 5, 2013 · 5 comments
Closed

Users in other sites but not main site will not have any roles #22

luiges90 opened this issue Sep 5, 2013 · 5 comments

Comments

@luiges90
Copy link

luiges90 commented Sep 5, 2013

In multisite Wordpress installations, if users are registered in other sites but not the main site, they will not have any roles when loaded by this bundle.

It is because the meta key is hardcoded in https://github.com/kayue/KayueWordpressBundle/blob/master/Model/User.php#L324

@luiges90
Copy link
Author

I think it is not possible to determine which blog_id we should use simply in the abstraction layer of this bundle. The blog_id would be passed from higher abstraction layer.

i.e. The user would determine when to use the settings from site 1 (wp_capabilities), when to use site 2 (wp_2_capabilities), etc...

To make $this->get('security.context')->isGranted('ROLE_WP_ADMINISTRATOR') work, we need to somehow let the security context knows which site we are talking about.

I am thinking about creating multiple security contexts. However, to make our bundle works in any number of sites, we would need to somehow create a Security Context Factory, and this entails a Firewall Factory. Can Symfony do that? hm...

A mere constant explodes into much more difficult solution, ouch...

Let's see if there are easier way first.


As a side note, we could use Firewall request matchers if we need to decide which firewall to use by host.

@luiges90
Copy link
Author

A quick, dirty and inherently stupid way would be add a new method getRolesOfSite($site) in User, but this wouldn't be able to take advantage of Symfony role hierarchy and this would cause code duplication (coding the hierarchy in many places)

@luiges90
Copy link
Author

Looking into securityContext->isGranted and see if we can change something in it

@mattsnowboard
Copy link

Also, what about the "site_admins" key in "wp_sitemeta"?
I'd like to add a ROLE_WP_SUPER_ADMIN role in that case.

But I think that involves adding support to read that table into entities, then decoding that key into an array and searching for the user in that array. I'm not sure the best place to put it in. I suppose it would have to happen around when the user is loaded from the provider?

@kayue
Copy link
Owner

kayue commented Dec 2, 2014

@mattsnowboard Actually you can use Security Voter in Symfony to check user role.

Somthing similar to this: https://gist.github.com/kayue/f563394b7ee35a326aad

@kayue kayue closed this as completed Dec 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants