catalyst / moodle-auth_saml2

SAML done 100% in Moodle, fast, simple, secure
https://moodle.org/plugins/auth_saml2
70 stars 131 forks source link

Deep links with multiple IDPs #229

Open MartinSandberg opened 6 years ago

MartinSandberg commented 6 years ago

Would it be possible for you to add a snippet of code to allow for deep links that.

I tried this out locally and it works, you might possibly want to rewrite the code.

  1. Adding another optional parameter samlidp

So any deeplink into the site with saml=1&samlidp=NameOfOneOfMultipleIDPs added would take the user directly to the correct IDP.

in function saml_login() ....... // Set the default IdP to be the first in the list. Used when dual login is disabled. $arr = array_reverse($saml2auth->idpentityids); $idp = md5(array_pop($arr));

    // XTRACTOR addition for autologin with multiple idps
    $samlidp = optional_param('samlidp', null, PARAM_TEXT);
    if (!empty($samlidp)){
        foreach ($this->idplist as $idp) {
            if ($idp->idpname == $samlidp){
                $idp = md5(array_pop($arr));
            }
        }
    }
    // END XTRACTOR

    // Specify the default IdP to use.
    $SESSION->saml2idp = $idp;

......

brendanheywood commented 5 years ago

Can you rework this into a pull request please?

brendanheywood commented 5 years ago

This feels like a missing part of multi-idp support, if there are many then this should be reflected in:

loginpage_idp_list()

And these deep links should there too