Skip to content

Add test authentication sources with same SP entityID #2417

Open

Description

@bilias

Hi,
I have a working setup of and SP/IDP bridge with latest version of simpleSAMLphp.

Metadata of my simpleSAMLphp SP are in federation and pulled from remote SPs.

I want to add IDPs in authsources.php (/module.php/admin/test) in order to directly test certain IDPs without going over disco.
If I go over disco then everything works ok.

However if I want to direct add specific IDPs in authsources.php then this does not work unless I use a new
entityID for the SP, and manually add the new SP's metadata in the remote IDP.
The problem is the AssertionConsumerServiceURL which is wrong, because it uses the name of the array and I cannot find a way to override this one.

My entityID of the SP which exists in federation's metadata is something like:
https://sp.example.com/sp

I want to add test authsources like this:

    'idp.example.com' => [
        'saml:SP',
        'debug' => true,
        'entityID' => 'https://sp.example.com/sp-idp.example.com',
        //'entityID' => 'https://sp.example.com/sp', // NOT WORKING
        'idp' => 'https://idp.example.com/idp/shibboleth',

        'privatekey' => '/var/www/html/saml/simplesamlphp/cert/saml.key',
        'certificate' => '/var/www/html/saml/simplesamlphp/cert/saml.crt',

        'name' => [
            'en' => 'idp.example.com',
        ],
    ],

With the desired entityID https://sp.example.com/sp I get an error of:
- Profile Action PopulateBindingAndEndpointContexts: Unable to resolve outbound message endpoint for relying party 'https://sp.example.com/sp': EndpointCriterion [type={urn:oasis:names:tc:SAML:2.0:metadata}AssertionConsumerService, Binding=urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST, Location=https://sp.example.com/module.php/saml/sp/saml2-acs.php/idp.example.com, trusted=false]
because the SP sends
AssertionConsumerServiceURL="https://sp.example.com/module.php/saml/sp/saml2-acs.php/idp.example.com"

The problem arrives from
/idp.example.com in AssertionConsumerServiceURL instead of /sp

Reading
https://simplesamlphp.org/docs/stable/simplesamlphp-sp.html and
https://simplesamlphp.org/docs/stable/saml/sp.html

I cannot find a way to override this name

my 'sp' => configuration is fine but it goes over disco.

Is this on purpose? Maybe I ask for a new feature, not sure.

This happens in

$ar->setAssertionConsumerServiceURL(Module::getModuleURL('saml/sp/saml2-acs.php/' . $this->authId));

but this is not the only place.

I 've also found this one:
https://github.com/simplesamlphp/simplesamlphp/blob/master/docs/simplesamlphp-metadata-endpoints.md

and added:

      'AssertionConsumerService' => [
         [
        'index' => 1,
        'isDefault' => true,
        'Location' => 'https://sp.example.com/module.php/saml/sp/saml2-acs.php/sp',
        'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
         ],
         [
        'index' => 2,
        'Location' => 'https://sp.example.com/module.php/saml/sp/saml2-acs.php/sp',
        'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
         ],
      ],
       'SingleLogoutServiceLocation' => 'https://sp.example.com/module.php/saml/sp/saml2-logout.php/sp',

but still didn't work.
It again send the wrong AssertionConsumerServiceURL. This probably only changes the metadata for this IDP.
Thanks

Activity

  1. descalada commented on May 16, 2025

    @descalada

    Hello,

    I am not an expert but I have been the last days trying to figure this out. It was completely lack of knowledge on my side. As far as I understood AssertionConsumerService is not use to generate the URL but it is used to validate that the AssertionConsumerServiceURL that comes in the message or the index is in your declaration of the IdP/SP, so you do not send messages to any endpoint and are subjected to an attack.

    Again, very simple point of view.

    The easiest way I found to change this is to set the baseurl in your config.php as a full url, something like http://your_host/simplesaml

    Thanks

  2. bilias commented on May 16, 2025

    @bilias
    Author

    Yes indeed.
    I've changed $baseurlpath from "/" to full url and now both tests for both idps work!

    Thanks :)

  3. bilias commented on May 16, 2025

    @bilias
    Author

    No I was wrong. Still the same problem.

    I logged in because I had custom entityIDs and custom metadata pushed (in order to make the test work).
    Getting back the default entityID (https://sp.example.com/sp) fails again:

    Remote idp shows:

    • Profile Action PopulateBindingAndEndpointContexts: Unable to resolve outbound message endpoint for relying party 'https://sp.example.com/sp': EndpointCriterion [type={urn:oasis:names:tc:SAML:2.0:metadata}AssertionConsumerService, Binding=urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST, Location=https://sp.example.com/module.php/saml/sp/saml2-acs.php/idp.example.com, trusted=false]
  4. tvdijen commented on May 17, 2025

    @tvdijen
    Member

    However if I want to direct add specific IDPs in authsources.php then this does not work unless I use a new entityID for the SP, and manually add the new SP's metadata in the remote IDP.

    Correct. This is how it works.

    The problem is the AssertionConsumerServiceURL which is wrong, because it uses the name of the array and I cannot find a way to override this one.

    I don't understand how you get from the previous sentence to this one, and why you think ACS-url is wrong. It is supposed to use the array-key to be able to uniquely identity the SP-authsource. You should never even think about overriding this.

    So let's get back one step so I can try to understand what's happening here. You have one SP-authsource that is used by your bridge that shows the discovery-page. That one is working fine, right? Now you want to add an additional one to target a specific IdP for testing-purposes. This basically means you can copy-paste the bridge-SP configuration into a new entry and give it a unique array-key, and set the idp setting to target that specific IdP.

    Now there are two things you can do: you give the test-SP a unique entityID, or you re-use the one from the bridge-SP. The first option means you have to exchange the metadata for this test-SP with your IdP, because it has to know about this new entity. For the second option this isn't necessary, because the bridge-SP is already known to the IdP and you're re-using it's entityID, however, the request will contain an ACS-url or index that is unknown to the IdP.

    IdP's have two ways to be persuaded into posting an assertion to a remote entry; it has to known this specific ACS-url/index based on the metadata it has, or the AuthnRequest comes from a known entity and is signed. The first option involves adding the ACS-endpoint of the test-SP to the metadata of the bridge-SP, by setting the AssertionConsumerServive on the bridge-SP. Note that you have to exchange the updated metadata with the IdP. The second option only requires you to set 'redirect.sign' => true on the test-SP, so the requests will be signed. The IdP should accept the unknown ACS-endpoint (although it might need configuration on the IdP to enable this behaviour).

  5. bilias commented on May 19, 2025

    @bilias
    Author

    Thanks @tvdijen for the extensive and most informative reply.

    I believe I do understand better now. Array settings in authsources actually define new SPs. My understanding was that it had to do with (remote) idp configuration. I was hoping I would be able to "overload" the default SP with different default IDPs via different configurations in the arrays.

    Both my SP and my (test) IDPs metadata are inside federation so I would prefer I didn't exchange new custom metadata with IDPs and use the default SP (bridge) metadata for my test-IDPs. So that would be option 2.

    So let's get back one step so I can try to understand what's happening here. You have one SP-authsource that is used by your bridge that shows the discovery-page. That one is working fine, right?

    Correct. disco works fine.

    Now you want to add an additional one to target a specific IdP for testing-purposes. This basically means you can copy-paste the bridge-SP configuration into a new entry and give it a unique array-key, and set the idp setting to target that specific IdP.

    Yes this is what I did.

    Now there are two things you can do: you give the test-SP a unique entityID, or you re-use the one from the bridge-SP. The first option means you have to exchange the metadata for this test-SP with your IdP, because it has to know about this new entity.

    Yes, that part works ok.

    For the second option this isn't necessary, because the bridge-SP is already known to the IdP and you're re-using it's entityID, however, the request will contain an ACS-url or index that is unknown to the IdP.

    Correct. It creates ACS Location URLs based on array key name. These are different than the default SP's URLs which exist in metadata and are knows to idps.

    What if there was a new variable inside saml:SP array like
    'my_custom_ACS_endpoint' => 'sp'; // use default SP's name
    which would be used to create ACS urls same as default SP's instead of using the array key 'idp.example.com'
    /module.php/saml/sp/saml2-acs.php/sp and not
    /module.php/saml/sp/saml2-acs.php/idp.example.com

    Does this makes sense or would this create other problems like some kind of loop?
    I'm talking about patching simplesamlphp for this to accept and use a new var for this.

    IdP's have two ways to be persuaded into posting an assertion to a remote entry; it has to known this specific ACS-url/index based on the metadata it has, or the AuthnRequest comes from a known entity and is signed. The first option involves adding the ACS-endpoint of the test-SP to the metadata of the bridge-SP, by setting the AssertionConsumerServive on the bridge-SP. Note that you have to exchange the updated metadata with the IdP.

    The second option only requires you to set 'redirect.sign' => true on the test-SP, so the requests will be signed. The IdP should accept the unknown ACS-endpoint (although it might need configuration on the IdP to enable this behaviour).

    Tried that, I saw and exchanged the new metadata with AuthnRequestsSigned="true" inside, but the idp still didn't accept the unknown ACS endpoint.
    My shibboleth idp probably requires something extra but can't find it.

    I'm also concerned about security here even if it's accepted. ok the Authn requests would be signed, which means access to the private key, but still rogue URLs could be passed.

    In any case this needs custom configuration on the IDP side. Better exchange metadata (option 1).

    Does the idea of the patch I'm proposing makes any sense. I could have a look and write something.

    Thanks

  6. tvdijen commented on May 19, 2025

    @tvdijen
    Member

    Hmm, I'm having second thoughts about the second option.. I'm pretty sure the behaviour is described somewhere, but I cannot find it in any documentation, so let's forget about it.

    I think we hit a bug, because if I override the AssertionConsumerService, I expect it to not only change the SP-metadata, but also to use that value in the AuthnRequest.. That last part is not happening and should probably be fixed. Allow me a little bit of time to think this through.

    ** Edit ** : I did find the documentation for the second option!

    "3.4.1 Element AuthnRequest" of the SAML2 core specifications say:

    AssertionConsumerServiceURL [Optional]
    Specifies by value the location to which the message MUST be returned to the
    requester. The responder MUST ensure by some means that the value specified is in fact associated
    with the requester. [SAMLMeta] provides one possible mechanism; signing the enclosing
    message is another.

    Shibboleth should honour that.

  7. bilias commented on May 19, 2025

    @bilias
    Author

    ** Edit ** : I did find the documentation for the second option!

    "3.4.1 Element AuthnRequest" of the SAML2 core specifications say:

    AssertionConsumerServiceURL [Optional]
    Specifies by value the location to which the message MUST be returned to the
    requester. The responder MUST ensure by some means that the value specified is in fact associated
    with the requester. [SAMLMeta] provides one possible mechanism; signing the enclosing
    message is another.

    Shibboleth should honour that.

    Just for the record, there is an interesting discussion about this here:
    https://groups.google.com/g/simplesamlphp/c/4rHive1HF9M
    https://groups.google.com/g/simplesamlphp/c/xOq3Iir0pkA

  8. tvdijen commented on May 19, 2025

    @tvdijen
    Member

    Yes, so according to Peter, there must be a setting in Shibboleth. That might be worth investigating for you while I work on a fix for the ACS-configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions