flipboxfactory / saml-sp

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

Different Entity id based on current hostname #76

Closed dennismeissner closed 4 years ago

dennismeissner commented 4 years ago

Hey Damien,

it's me again ;)

After half a year using your plugin for multiple thousands of users, i must say it is really stable and works pretty well. We are very happy with it 👍

Today we want to add support for a different domain. i try to explain:

http://domain1.com/ - current entity under settings and in My Provider

Wenn i go to domain1.com i get redirected to id.domain1.com where i can login. After that i get redirected to domain1.com. Perfect!

Now i want to add another Identity Provider. And i also want Craft CMS to be available via https://domain1.com and alsop https://comain2.com

My expactation: go to domain1.com -> redirect to id.domain1.com -> login -> redirect to domain1.com go to domain2.com ->redirect to id.domain2.com -> login -> redirect to domain2.com

But unfortunately, because i can only set the entity in the system settings, when i go to domain2.com i get a simplesaml error that no entity data is found for domain1.com

Do you have any idea how i can get around this?

dsmrt commented 4 years ago

First off, thanks for the kind words. We do our best! I'm glad it's working out! 😄

Are you using Craft CMS multi-site here? It sounds like you are with domain2.com.

If that is the case, you can actually use an environmental variable for the EntityID and switch that env var based on the site url.

See for reference: https://github.com/flipboxfactory/saml-core/blob/3.0.1/src/models/AbstractSettings.php#L112

You can change that value in settings. Just be careful the existing entity id/configuration (see screenshot below). You'll have to line-up the environment correctly so that new variable works with the old entity id.

Screen Shot 2020-08-13 at 5 51 02 PM

Hopefully this helps!

dennismeissner commented 4 years ago

Thanks for pointing me in the right direction. i did solve this by overwriting the entityId value to:

'entityId' => $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . '/'

in your config/saml-sp.php

That should work for all sites and always in my special case.