Skip to content

Commit

Permalink
feat(PassthroughParameters): Make it possible to pass through paramet…
Browse files Browse the repository at this point in the history
…ers to the SAML library

OneLogin/Auth->login can accept an array of parameters to be passed through to the IdP.

This patch makes it possible to specify an array of parameters to be passed through to the IdP in config.php.

For example, you can set it like this, and if we get such a parameter in
the request to user_saml/saml/login we will pass it on to the IdP.
  'user_saml.passthrough_parameters' => ['idp_hint'],
  • Loading branch information
mickenordin committed Nov 5, 2024
1 parent 03e8026 commit e343fb3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/Controller/SAMLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,18 @@ public function login(int $idp = 1): Http\RedirectResponse {
switch ($type) {
case 'saml':
$auth = new Auth($this->samlSettings->getOneLoginSettingsArray($idp));
$passthroughParams = $this->config->getSystemValue('user_saml.passthrough_parameters', []);
$passthroughValues = [];
foreach ($passthroughParams as $passthroughParam) {
$value = (string)$this->request->getParam($passthroughParam, '');
if ($value !== '') {
$passthroughValues[$passthroughParam] = $value;
}
}


$returnUrl = $originalUrl ?: $this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.login');
$ssoUrl = $auth->login($returnUrl, [], false, false, true);
$ssoUrl = $auth->login($returnUrl, $passthroughValues, false, false, true);
$response = new Http\RedirectResponse($ssoUrl);

// Small hack to make user_saml work with the loginflows
Expand Down

0 comments on commit e343fb3

Please sign in to comment.