aacotroneo / laravel-saml2

A Laravel 5 package for Saml2 integration as a SP (service provider) based on the simple OneLogin toolkit
MIT License
567 stars 238 forks source link

Add token on redirect when hit login url #173

Open busharthussain opened 5 years ago

busharthussain commented 5 years ago

I want to add extra paramters in that login function but this function is present in vendor file. how i can send extra paramters in that function before redirect ?

public function login($returnTo = null, array $parameters = array(), $forceAuthn = false, $isPassive = false, $stay = false, $setNameIdPolicy = true) { $authnRequest = new AuthnRequest($this->_settings, $forceAuthn, $isPassive, $setNameIdPolicy);

    $this->_lastRequest = $authnRequest->getXML();
    $this->_lastRequestID = $authnRequest->getId();

    $samlRequest = $authnRequest->getRequest();
    $parameters['SAMLRequest'] = $samlRequest;

    if (!empty($returnTo)) {
        $parameters['RelayState'] = $returnTo;
    } else {
        $parameters['RelayState'] = Utils::getSelfRoutedURLNoQuery();
    }

    $security = $this->_settings->getSecurityData();
    if (isset($security['authnRequestsSigned']) && $security['authnRequestsSigned']) {
        $signature = $this->buildRequestSignature($samlRequest, $parameters['RelayState'], $security['signatureAlgorithm']);
        $parameters['SigAlg'] = $security['signatureAlgorithm'];
        $parameters['Signature'] = $signature;
    }
    return $this->redirectTo($this->getSSOurl(), $parameters, $stay);
}
albertStaalburger commented 4 years ago

Good day @busharthussain

Simply extend Aacotroneo\Saml2\Http\Controllers\Saml2Controller and overwrite the login function providing the desired parameters you want added. e.g.

public function login()
{
    $returnTo = '/';
    $parameters = array(); // specify parameters here
    ...
    $this->saml2Auth->login($returnTo, $parameters, $forceAuthn, $isPassive, $stay, $setNameIdPolicy);`
}