flipboxfactory / saml-sp

SAML Service Provider (SP) Plugin for Craft CMS
https://saml-sp.flipboxfactory.com/
Other
19 stars 5 forks source link

One more time: Workarounding Multi-Sites #145

Closed hiasl closed 2 years ago

hiasl commented 2 years ago

Hi, although many issues here cover the multi-site problem, I'm still not sure how to proceed:

First of all, I read

Our setup:

What I achieved:

What I found out or believe should be working:

Is this a problem? Is this siteId used for anything else than resolving the CP's domains when creating the metadata xml? In #136 some ideas came up, and if I understand it correctly, they also cover my problems, right?

Thanks for you assistance.

dsmrt commented 2 years ago

👋 @hiasl ,

Thanks for the leg work here and clearly defining your issue. It seems clear and shows me that maybe the project config isn’t the best solution for everyone if we develop a code based solution.

The site id is to help with users defining the baseUrl for the site in the metadata.

Maybe i can find a solution for a temporary fix for your current situation and think harder on how to update the plugin for #136

Let me get back to you on the temporary solution.

hiasl commented 2 years ago

Hey @dsmrt from my point of view being able to put all the necessary configs and data into a config/local.saml.php file (or something like that), which is not part of my GIT repo, but is placed by my deployment process only, would be the easiest solution.

And regarding my issue: do you think my procedure would work for the moment? I will not modify/save the service provider list on my "non-allowAdminChanges" zones, so the metadata xml will not be recreated.

Thanks

dsmrt commented 2 years ago

I might have misunderstood.

Correct me if I'm wrong, but your trying to find a solution to the lack of multi-environment support by creating a site for each environment?

If that is the case, this would be problematic do to the relational nature of the provider linking to the site in the provider tables.

You can probably use an environmental variable for the CP site base url and one by one change that env var to the base url while creating the sp providers in the plugin.

Steps to do this:

  1. Set the env var in the .env (for example $CP_SITE_URL=localhost:8080, maybe start with the local cp site url) and assign it to the site. Save the site and commit project config change to the repo.
  2. Create the SP/provider for the current site (using the example host, https://localhost:8080/admin/saml-sp/metadata/new-sp)
    • make sure to set the entity id accordingly. If the base url is https://localhost:8080/ use https://localhost:8080/, if it's https://dev.mysite.com/ use https://dev.mysite.com/.
    • make sure to select the site and key pair as needed
  3. repeat 1 and 2 on the next "zone"

Does that make sense?

hiasl commented 2 years ago

Does your solution suggest that I create 1 singular CP site instead of one for each zone? And this one site gets $CP_SITE_URL as Base URL? And it gets transferred to the other zones via project-config?

My "problem" is, that I do not want to have the CP sites in my project config / on all other zones, even if they are deactivated, because in some places users will see them and be confused. Apart from that I heard that creating multi-sites (especially useless ones) might become a multiplier on database size.

I think my real problem is, that the SSO URLs contained at the end of my service providers metadata XMLs take their base URLs from the related sites, which is not handy when you work with separate CP URLs.

dsmrt commented 2 years ago

Does your solution suggest that I create 1 singular CP site instead of one for each zone? ...

yes

And this one site gets $CP_SITE_URL as Base URL? ...

yes, although you'd change that variable value based on the zone, I'd assume

And it gets transferred to the other zones via project-config?

yes, the site id is saved for the provider record and I can't guarentee things will work if the site doesn't exist.

I understand your concern about the confusion and it contributing to the size of the db but a site needs to associated to the provider for the plugin to work correctly as it is today. It's also pretty handy for the majority of use cases. It makes configuring much easier than an open text field that might confuse users more than help.

As you know, I am currently evaluating the complexity of some of the multi-environment aspects of the plugin and will take your concerns into consideration.

hiasl commented 2 years ago

ok, thank you, I appreciate your help very very much! I will try (maybe also without transferring the CP site), and post my experiences her.

dsmrt commented 2 years ago

Let me know how this goes. I appreciate the insight!

hiasl commented 2 years ago

Thanks again Damien, with your help we found a solution that works for us.

Our environment / requirements:

Our expectations:

The problem:

Solution: