Repository navigation
Description
Is your feature request related to a problem? Please describe.
Yes.
In short:
SwitchWAYF discovery service trigger issues with this namespace added in SimpleSAMLPhP metadatas as of version 2.4.x:
xmlns:idpdisc="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol"
<md:Extensions> <idpdisc:DiscoveryResponse xmlns:idpdisc="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol" Binding="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol" Location="https://..../simplesaml/module.php/saml/sp/discoResponse/<aut-source-sp>" index="0"/> </md:Extensions>
Details:
The new branch 2.4 of SSP introduced a mandatory endpoint for DiscoveryResponse, this EVEN if the discoURL config in authsources point to an external discovery service.
At Belnet (Belgian NREN), we are making use of SimpleSAMLPhP as SP for some of our services, like FileSender.
Our authsources.php config is set to redirect to an external Discovery Service which is built with the SwitchWAYF:
'discoURL' =>
The discovery service (based on SwitchWAYF) is then providing a list of IdP's members in the Belnet's R&E federation.
We publish our SP (Filesender) metadatas in the Belnet's R&E federation global metadata file using the Metadata SAML URL provided on SP admin module.
The version of SwitchWAYF that we use is incompatible with the sections in the SP metadata of the namespace related to idp-discovery-protocol introduced since version 2.4 .
Describe the solution you'd like
Obtain the construction of the SP metadata without including the namespace related to idp-discovery-protocol
Here are two approaches:
- Disable DiscoveryResponse when using an external discovery service (i.e. when discoURL is configured in authsources.php)
(referred as Method A hereunder)
OR - Disable DiscoveryResponse explicitly through metadata option
(referred as Method B hereunder)
Describe alternatives you've considered
I tested both approaches (method A & method B) with a test instance of our FileSender service, running version 2.4.2 of SimpleSAMLPhP
This was done by modifying the SP metadata construction so that it no longer included any references of the namespace idp-discovery-protocol.
To achieve this, I successfully tested both methods by modifying the file modules/saml/src/Auth/Source/SP.php
- Method A: Disable DiscoveryResponse when using an external discovery service (i.e. when discoURL is configured in authsources.php)
/**
* Retrieve the metadata array of this SP, as a remote IdP would see it.
*
* @return array The metadata array for its use by a remote IdP.
*/
public function getHostedMetadata(): array
{
$entityid = $this->getEntityId();
$metadata = [
'entityid' => $entityid,
'metadata-set' => 'saml20-sp-remote',
'SingleLogoutService' => $this->getSLOEndpoints(),
'AssertionConsumerService' => $this->getACSEndpoints(),
];
// METHOD A: Disable DiscoveryResponse when using an external discovery service
// (i.e. when discoURL is configured in authsources.php)
if (empty($this->metadata->getOptionalString('discoURL', null))) {
$metadata['DiscoveryResponse'] = $this->getDiscoveryResponseEndpoints();
}
...
- Method B: Allow the choice of whether to use the DiscoveryResponse extension. Requires a parameter in authsources.php.
'disable.DiscoveryResponse' => true,
/**
* Retrieve the metadata array of this SP, as a remote IdP would see it.
*
* @return array The metadata array for its use by a remote IdP.
*/
public function getHostedMetadata(): array
{
$entityid = $this->getEntityId();
$metadata = [
'entityid' => $entityid,
'metadata-set' => 'saml20-sp-remote',
'SingleLogoutService' => $this->getSLOEndpoints(),
'AssertionConsumerService' => $this->getACSEndpoints(),
];
// METHOD B: Disable DiscoveryResponse explicitly through a config parameter in authsources.php
if (!($this->metadata->getOptionalBoolean('disable.DiscoveryResponse', false))) {
$metadata['DiscoveryResponse'] = $this->getDiscoveryResponseEndpoints();
}
...
Here is an example of metadata obtained by applying method B.:
Additional context
I have not yet tested with one of the latest versions of SwitchWAYF, but it seems to me that the solution could be either:
-
not overloading the SP metadata with this namespace if an external Discovery Service is used by specifying its URL in authsources.php with “discoURL” => “<url_of_the_remote_DS>/”, (=Method A)
-
allowing sysadmins to enable or disable ‘support for IDP Discovery protocol’ with a configuration parameter (=Method B)
Here is the error we get with SSP >2.4.0 and SwitchWAYF, without the code modification suggested above, after authentication by our IdPs:
Conclusion
Do you agree with any of the suggestions above?
I'll leave it up to you to decide which of my suggestions is the best solution.
Activity
monkeyiq commentedon Dec 19, 2025
Thank you for the detailed issue report (and two embedded PRs to choose from) :)
The default addition of
DiscoveryResponsewas included in the commit just before this comment #2402 (review)It is mentioned as a "crucial thing" to do. I will have to dig further into the specs to fully understand it.
In the short term I don't mind the idea of making this optional so that existing systems work.
monkeyiq commentedon Dec 19, 2025
@thijskh I am very interested in your thoughts on being able to relax this code?
thijskh commentedon Jan 6, 2026
This indeed seems like a very valid request and I think option A makes sense & has the advantage that it does 'the right thing' automatically and not require extra actions or complexity for the deployer.
Ludovic-Belnet commentedon Apr 15, 2026
Dear @thijskh
I have looked into this Discovery Service issue in more detail, given that you have not yet modified your code in line with my previous suggestions of 8 December 2025.
Problem statement (what breaks)
Since SimpleSAMLphp 2.4.x, the SP metadata generated by the SAML module includes an idpdisc:DiscoveryResponse endpoint whose Location contains the authsource suffix:
<md:Extensions> <idpdisc:DiscoveryResponse Binding="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol" Location="https://<sp>/simplesaml/module.php/saml/sp/discoResponse/<authsource>" index="0"/> </md:Extensions>This is the exact behaviour described in this issue #2573 (the DiscoveryResponse is added by default since 2.4.x).
However, during an actual login flow using an external Discovery Service (DS), the DS returns the user to the SP using the unsuffixed endpoint:
This is not just an observation: the SAML module routing defines the DS callback as a global route without {sourceId} (no authsource in the path).
Many DS implementations perform an anti‑phishing check: they verify that the return URL they are asked to redirect to is among the SP’s published DiscoveryResponse URLs. Federation guidance explicitly recommends this trust check, and warns that discovery flows fail if DiscoveryResponse is not trusted / matching.
Result: metadata publishes a suffixed DiscoveryResponse, but runtime uses an unsuffixed return URL → DS cannot verify the return URL → login fails (e.g., “Unverified return URL”).
What i identified (step‑by‑step, reproducible)
What SSP publishes (metadata)
SSP 2.4.x generates SP metadata including:
idpdisc:DiscoveryResponse Location=".../discoResponse/" (suffix included).
The extension itself is documented by SSP as the standard OASIS IdP Discovery metadata extension.
What SSP uses at runtime (DS callback)
In SSP 2.x routing, the DS callback is:
This matches the well‑known “standard URL” used by deployments:
Why external DS refuses (security model)
Discovery Services typically verify that the return parameter is a trusted URL listed in metadata as a DiscoveryResponse endpoint. This is a recommended security measure to mitigate phishing and open redirects.
So if the DS receives:
but the SP metadata only contains:
then the DS can legitimately reject the redirect as untrusted (“Unverified return URL”).
Why this is confusing for deployers
Even if deployers try to configure DiscoveryResponse explicitly in authsources.php (as described by SSP docs), SSP 2.4.x still generates a suffixed value in hosted metadata. In practice, operators can “fix” the problem only by manually editing metadata in the federation and removing the suffix—exactly what we observed.
Impact
Breaks upgrades to SSP ≥ 2.4 for SPs using an external Discovery Service, because DS return URL verification fails.
Forces operators into insecure workarounds (disabling DS checks) or ongoing local patching / manual metadata edits.
Root cause
In short, there is a mismatch between:
External DS implementations validate return vs. published DiscoveryResponse, so the mismatch breaks the DS flow.
Proposed fix
Publish the runtime endpoint by default
When SSP generates SP metadata, the default DiscoveryResponse Location should match the actual DS callback route:
(Optional) publish both endpoints for compatibility:
To avoid breaking any existing deployments that might rely on the suffixed URL, SSP can publish:
index 0: unsuffixed .../discoResponse (runtime correct)
index 1: suffixed .../discoResponse/ (compatibility)
Multiple DiscoveryResponse endpoints are valid and commonly supported by federation tooling and DS implementations.
Respect admin configuration
If DiscoveryResponse is explicitly set in authsources.php, SSP should HONOR that instead of overriding it with auto‑generated values (this aligns with SSP documentation). This is not currently the case.
https://simplesamlphp.org/docs/stable/simplesamlphp-metadata-extensions-idpdisc.html
Where in the code
The behaviour comes from hosted SP metadata generation in the SAML module (class SP), which currently adds DiscoveryResponse endpoints automatically. This is the same area referenced in this issue #2573 and where the earlier suggested change was applied experimentally.
The runtime DS callback route is defined separately in SAML module routing as /sp/discoResponse (no {sourceId}).
Proof that the fix works
If we manually publish SP metadata in the federation without the suffix, i.e.:
<idpdisc:DiscoveryResponse Location="https://<sp>/simplesaml/module.php/saml/sp/discoResponse" ... />then external DS verification succeeds and the login flow works.
Whereas publishing the suffix version reproduces “Unverified return URL”.
Final worlds
Could you please look into this situation for the next set of release?
Thank you
Ludovic