flipboxfactory / saml-sp

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

Loginpath by Sitedomain #63

Closed dennismeissner closed 4 years ago

dennismeissner commented 4 years ago

Until now, i only had one single IDP, but i have to implement a second IDP which is no problem using your interface.

What i am looking for is a solution for the default loginPath. e.g. if someone accesses my Site using domain: site-123.com i want send him to the idp configured as idp.site-123.com

if he comes on my site using domain: site-abc.com i want to send him to the idp configured as idp.site-abc.com

@dsmrt do you see any solution to this specific issue?

it is maybe as simple as (pseudo):

if domain is site-123.com
    goto idp.site-123.com
else if domain is site-abc.com
    goto idp.site-abc.com
end

but i need to find the best place to handle this. any suggestions?

dsmrt commented 4 years ago

@dennismeissner,

Good question!

Each IdP you configure has a unique request login endpoint. When you hit this login request endpoint, the plugin initiates the SSO process. You can use logic in the config/general.php to conditionally switch IdPs, something like so:

return [
    // Global settings
    '*' => [
        'loginPath' => (
            // OR use $_REQUEST['HTTP_HOST'] (or alternative) if BASE_URL isn't an environmental variable
            strpos('site-1234', getenv('BASE_URL')) ?
                '/sso/login/request/5fe363cd-d166-4758-bc88-634613bf0396' :
                '/sso/login/request/<uid-for-siteabc>'
        ),
    ],
];

You can find the UID based login request path under the IdP config settings in the admin. Screen Shot 2020-06-16 at 10 39 16 AM

dennismeissner commented 4 years ago

dude, thanks again for your fast help. This is very much what i was looking for!