Skip to content

Commit

Permalink
Add: possibility to use additional get-query parameters to SAML Reque…
Browse files Browse the repository at this point in the history
…st via SAMLConfiguration
  • Loading branch information
JakubDolba authored and satrun77 committed Aug 11, 2022
1 parent ebba936 commit 880b3ea
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
13 changes: 13 additions & 0 deletions docs/en/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ We assume ADFS 2.0 or greater is used as an IdP.
- [Allow insecure linking-by-email](#allow-insecure-linking-by-email)
- [Adjust the requested AuthN contexts](#adjust-the-requested-authn-contexts)
- [Create your own SAML configuration for completely custom settings](#create-your-own-saml-configuration-for-completely-custom-settings)
- [Additional GET Query Params for SAML](#additional-get-query-params-for-saml)
- [Resources](#resources)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -379,6 +380,18 @@ class MySAMLConfiguration
See the [advanced\_settings/\_example.php](https://github.com/onelogin/php-saml/blob/master/advanced_settings_example.php)
for the advanced settings.

### Additional GET Query Params for SAML
example:
```yaml
SilverStripe\SAML\Services\SAMLConfiguration:
additional_get_query_params:
someGetQueryParameter: 'value'
AnotherParameter: 'differentValue'
```

this configuration allows you to add two GET query parameters to endpoint request URL:
`https://your-idp.com/singleSignOnService/saml2?someGetQueryParameter=value&AnotherParameter=differentValue&SAMLRequest=XYZ....`

## Resources

- [ADFS Deep-Dive: Onboarding Applications](http://blogs.technet.com/b/askpfeplat/archive/2015/03/02/adfs-deep-dive-onboarding-applications.aspx)
17 changes: 16 additions & 1 deletion src/Helpers/SAMLHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ public function redirect(RequestHandler $requestHandler = null, HTTPRequest $req
$request->getSession()->save($request);
}

$additionalGetQueryParams = $this->getAdditionalGETQueryParameters();

try {
$auth->login(Director::absoluteBaseURL() . 'saml/');
$auth->login(Director::absoluteBaseURL() . 'saml/', $additionalGetQueryParams);
} catch (Exception $e) {
/** @var LoggerInterface $logger */
$logger = Injector::inst()->get(LoggerInterface::class);
Expand Down Expand Up @@ -125,4 +127,17 @@ public function binToStrGuid($object_guid)
$hex_guid_to_guid_str .= '-' . substr($hex_guid, 20);
return strtoupper($hex_guid_to_guid_str);
}

/**
* @return string[]
*/
private function getAdditionalGETQueryParameters()
{
$additionalGetQueryParams = $this->SAMLConfService->config()->get('additional_get_query_params');
if (!is_array($additionalGetQueryParams)) {
$additionalGetQueryParams = [];
}

return $additionalGetQueryParams;
}
}
8 changes: 8 additions & 0 deletions src/Services/SAMLConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ class SAMLConfiguration
*/
private static $expose_guid_as_attribute = false;

/**
* @config
* @example ['GET Query Parameter Name' => 'Parameter Value', ... ]
*
* @var string[]
*/
private static $additional_get_query_params = [];

/**
* @return array
*/
Expand Down

0 comments on commit 880b3ea

Please sign in to comment.