function _saml_sp__extract_outbound_id in SAML Service Provider 4.x
Same name and namespace in other branches
- 8.3 saml_sp.module \_saml_sp__extract_outbound_id()
- 8.2 saml_sp.module \_saml_sp__extract_outbound_id()
- 7.8 saml_sp.module \_saml_sp__extract_outbound_id()
- 7 saml_sp.module \_saml_sp__extract_outbound_id()
- 7.2 saml_sp.module \_saml_sp__extract_outbound_id()
- 7.3 saml_sp.module \_saml_sp__extract_outbound_id()
- 3.x saml_sp.module \_saml_sp__extract_outbound_id()
Extract the unique ID of an outbound request.
Parameters
string $encoded_url: The response of AuthRequest::getRedirectUrl(), which is multiple-encoded.
Return value
string|false The unique ID of the outbound request, if it can be decoded. This will be AuthRequest::ID_PREFIX, followed by a SHA1 hash.
File
- ./
saml_sp.module, line 364 - SAML Service Provider.
Code
function _saml_sp__extract_outbound_id($encoded_url) {
$string = $encoded_url;
$string = @urldecode($string);
$string = @substr($string, 0, strpos($string, '&'));
$string = @base64_decode($string);
$string = @gzinflate($string);
// This regex is based on the constructor code provided in
// \OneLogin\Saml2\AuthnRequest.
$regex = '/^<samlp:AuthnRequest
xmlns:samlp="' . Constants::NS_SAMLP . '"
xmlns:saml="' . Constants::NS_SAML . '"
ID="(ONELOGIN_[0-9a-f]{40})"/m';
$result = FALSE;
if (preg_match($regex, $string, $matches)) {
$result = $matches[1];
}
return $result;
}