There is (as far as I know at least) no standard for transporting it
through SAML 2.0 authentication requests. It is possible to get it
through by defining your own protocol extension, but that means adding
support for that extension on both the SP and IdP.
By default, the simpleSAMLphp IdP will store known and unknown
extensions in the saml:Extensions field in the state array, so they
will be included when calling the authentication source. You will
probably have to create a custom authentication source in order to get
it into the login form though.
On the simpleSAMLphp SP side, you can add custom extensions to the
AuthnRequest by doing something like this:
$doc = new DOMDocument();
$element = $doc->createElementNS('your-extension-namespace-URI', 'your-extension-element');
$element->appendChild($doc->createTextElement('contents'));
$xmlChunk = new SAML2_XML_Chunk($element);
$as = ...;
$as->requireAuth(array(
[...],
'saml:Extensions' => array(
$xmlChunk,
),
));
Not entirely certain about the exact syntax, but I believe it is
something like that.
Of course, whether doing it this way is a good idea is another
question :) It means that you won't have full interoperability with
other SAML 2.0 implementations. It also requires a certain amount of
custom code to handle the extension.
Best regards,
Olav Morken
UNINETT / Feide
No helper function, but note that namespaceURI and localName are public
properties of the SAML2_XML_Chunk datatype. That should reduce the
overhead slightly.
However, not all saml:Extensions-elements need to be of the type
SAML2_XML_Chunk. (If it is a known extension, it will be parsed into
an appropriate object. Of course, there are no known extensions here
yet, but there may be in the future :)
A proper loop would be something like:
function getUsername(array $state) {
if (!isset($state['saml:Extensions'])) {
// No extensions in message.
return NULL;
}
foreach ($state['saml:Extensions'] as $ext) {
if (!$ext instanceof SAML2_XML_Chunk) {
continue; // Not our extension type - continue searching.
}
if ($ext->namespaceURI !== 'yournamespace' || $ext->localName !== 'yourelementname') {
continue; // Not our element - continue searching.
}
// We have the correct element - extract the username.
$xml = $ext->getXML();
$username = $xml->textContent;
return $username;
}
// We did not find our extension.
return NULL;
I agree, it would be very helpful for those admins like myself who are not full time programmers to be able to see a conceptual diagram of the authentication process (with notes referencing what modules do what) before beginning to install and customize simpleSAMLphp.
Thanks,
Sean
> > >Just to add to this, the state and save-state stuff really stumped me.
> > >I just did not understand what it was about and why it needed to be
> > >used like it does. Now I realise the authentication class, by default,
> > >does not involve any user interactive elements. Where it does need to
> > >interact with the user, the state is passed from the back-end
> > >authentication code to the front-end code (in the module's www
> > >directory).
It is designed to be flexible, but the price of that is complexity.
We have tried to provide a simple wrapper-class (UserPassBase) to
abstract away the most common code. But that fails when you have
special requirements, such as when you need to receive the
username from the SP.
> > >For people who have been working on this project for a long time,
> > >concepts like that are probably pretty obvious. But for people coming
> > >to the project fresh, pulling that out of the documentation is hard,
> > >very hard. I wonder if maybe there is an intermediate level missing -
> > >perhaps the framework described in some diagramatic form. Once the
> > >concepts of how it works, and what the parts of it are, the
> > >documentation can then point to where the components are and how to
> > >configure them.
> > >
> > >Perhaps it is just me? My aim isn't to criticise, but to point out
> > >areas that I believe may be holding back vast numbers of projects
> > >making use of this project (which may or may not be a blessing in
> > >disguise;-) just based on my own personal experience.
It's probably not just you. The problem is always time, and the lack
of it :)
> >
> > >-- Jason
> >
> > I agree, it would be very helpful for those admins like myself who are not full time programmers to be able to see a conceptual diagram of the authentication process (with notes referencing what modules do what) before beginning to install and customize simpleSAMLphp.
I made an attempt at creating a document displaying the authentication
process in a simpleSAMLphp IdP. See the attached file. Is that the type
of diagram that you are looking for? Of course, one would also need
some text to describe the purpose of the various boxes.
> >
> > Thanks,
> >
> > Sean
>
> Asking for something like this usually results in being volunteered to
> write it ;-) I would be happy to provide input where I can (I can
> explain what is not clear to a newbie like myself) but I don't feel I
> understand it enough to describe it correctly to others.
>
> One problem I have found with many (or most) of the examples I have
> seen, is that they are not upgrade safe. All examples of how to set
> things up tend to involve editing files that will be over-written on
> an upgrade.
What examples would that be? Not from our documentation I hope?
> It would be nice to know how to set up a system where all
> the custom files are new - a new module, a new config area, new entry
> points etc. so SSP sits unaltered in one place, and all the custom
> code sits separately to it. I do get the impression this is how it
> should work, but finding out how to do that is not easy. I would be
> happy to write up or draw up an example of how that could be done, for
> a small ring-fenced set of sites requiring SSO (that's my use-case,
> and it works as I have set it up, but I feel it needs some refactoring
> to do it "properly").
Best regards,
The SP is logically (and most often physically) separate from the IdP,
so to do that you have to encode the information in SAML (since that's
how the SP and IdP communicate). Since you seem to be talking about
authentication information, you might want to look at SAML
AuthnContext, which was invented for this very purpose. Note, however,
that although SAML V2.0 has been in use for quite some time, the use
of AuthnContext is still in its infancy.
Tom