2

I need to generate with Simplesamlphp library an AuthnRequest with the following Extensions tag

<samlp:Extensions xmlns:spid="https://spid.gov.it/saml-extensions">
   <spid:Purpose>PX</spid:Purpose>
</samlp:Extensions>

In Simplesamlphp's documentation is explained how to generate an Extensions' child with namespace, but it's not clear if it's possible to add a namespace to Extensions tag itself.

Any suggestion/clarification?

1 Answers1

0

I've been working for some weeks to update our version of simplesamlphp, we provide SPID, CIE, SPID eIDAS, ...

My company was using a version of the library from 2010 when I came here, after many many struggles I managed to update SPID completely and I'm almost done with CIE (and then there's the rest!). Hope I can help you a bit for all I suffered.

To fix this issue I did this:

  • added these rows inside vendor/simplesamlphp/saml2/src/SAML2/XML/md/EntityDescriptor.php to declare these namespaces globally (one for SPID and one for CIE)

      if($this->getIncludeSPIDns() === true){ //[EC] 14-03-'22
          $e->setAttribute ( 'xmlns:spid', 'https://spid.gov.it/saml-extensions' );
      }
      if($this->getIncludeCIEns() === true){ //[EC] 14-03-'22
          $e->setAttribute ( 'xmlns:cie', 'https://www.cartaidentita.interno.gov.it/saml-extensions' );
      }
    

I had to modify some files and declare these properties and their getters inside the EntityDescriptor class, because I wanted them to be dinamic:

(config/authsources.php)

'IncludeCIEns' => true, //Se impostato aggiunge il namespace (globalmente)

To add the Extensions block I did this:

  1. I declared these properties inside the contacts property on config/authsources.php

enter image description here

  1. I marked these new properties as valid (so SAML would "pick them up") inside lib/SimpleSAML/Utils/Config/Metadata.php

enter image description here

  1. I read these values on lib/SimpleSAML/Metadata/SAMLBuilder.php (this is the addContact function)

enter image description here

  1. I add the Extensions block and his children inside vendor/simplesamlphp/saml2/src/SAML2/XML/md/ContactPerson.php

enter image description here

Quick edit: I'm working with simplesamlphp 1.18.8 from 2020-09-02

P.S.: I wanted to provide code, I resorted to screenshots because of stackoverflow, what a waste of time just to post an answer. It was always saying my code wasn't indented properly (even if it was...), couldn't post my answer like it was, I resorted to enclosing it in pre tags (because the code sample wasn't working), it wasn't enough for this fancy site, had to convert them to screenshot...

Manuch
  • 49
  • 1
  • 8