SAML assertion with username/password - what do the messages really look like?
Asked Answered
I

1

11

I need to create a some SAML 2.0 assertions, and I'm having trouble finding what the XML should really look like. Most of the documentation seems to be about using particular tools, not about the messages. I've got the schemas, with a plethora of possibilities, but I can't find an example of what the relevant messages actually look like in practice.

The business rule says: in order to create a shared identity, the user tells system A their username and password on system B. System A needs to communicate this info (along with some demographics) to system B. System B validates the information and passes back a unique identifier which can then be used to refer to this user.

Could someone give me an example of what SAML 2.0 assertions would look like to carry this information?

FWIW, I'm using C#, and need to pass the XML around in ways which preclude using a 3rd-party tool.

Iconoscope answered 15/7, 2009 at 15:24 Comment(0)
J
27

I'm not sure your use case is quite what SAML 2.0 does.

What you describe as your business rules actually looks like a use case for identity provisioning, not access management.

Standard SAML 2.0 use cases focus on one party asserting identity (the identity provider) and the other party (or parties) relying on those assertions (the service provider). Assertions carry what's called a name identifier, use of which is agreed ahead of time between the identity provider and the service provider.

These name identifiers can be pretty much anything, but they broadly fall into two categories: transient and persistent. A transient name identifier is only useful in the context of the current session (and essentially only says, "I know who this person is") and tends to be used to protect the identity of the principal while allowing privileged access of some type. A persistent identifier can either be opaque (in a similar way to how OpenID is used to access SO) where the asserting party can repeatedly verify a principle's identity without disclosing their identity while maintaining a dynamic but stable shared identifier between the asserting and relying parties or more substantial, such as an Active Directory UPN (which can be pre-agreed ahead of time).

When it comes to passwords, as you mention in your question, the service provider (relying party) never sees the users password. The service provider hands the user over to the identity provider with an authentication request. The identity provider sends the user back to the service provider with a response, which in the case of successful authentication contains an assertion about the identity of the user in the context of the relationship between the identity provider and the service provider.

In context of your question, the big thing is that SAML 2.0 does not provide a way to either create the local "application" user account or link that local user account to a federated identity. This is simply not the problem SAML 2.0 tries to solve.

Now, back to your business rules...

It looks to me like what you're trying to do is either account linking or registration - I would approach it like this:

  • User visits application, clicks a button to use identity from the identity provider
  • The application produces an authentication request and directs the user to the identity provider, carrying that authentication request
  • The identity provider either logs in the user or reuses an existing identity session if the user has one. The IdP produces a response message containing an assertion about the user. In your case this assertion should at minimum carry a persistent name identifier. The identity provider directs the user back to the application, carrying the response message.
  • The application processes the response message. If a mapping entry exists for the persistent identifier passed the user is recognised from that mapping and logged in as that local application user. If no mapping entry exists the user can be asked to locally log in, and on successful local login the mapping entry can be produced, or a user account could be automatically created and the user could be asked to enter additional information (names, email addresses, etc.) The "corporate" use case would be that no automatic account linking or creation is allowed and that the mapping must exist ahead of time.

As for the content of the messages...

The OASIS Security Services Technical Committee has a zip file download available with extensive documentation of the parts of the XML schema, including examples. It's also well worthwhile reading the protocol and profile documentation, as these describe the flow of messages between the parties involved in the identity conversation.

There are a large number of presentations floating around that I found very useful. Specifically, SAML v2.0 Basics by Eve Maler helped me start realising what problems SAML v2.0 was trying to solve. This presentation includes examples of that assertions look like. There is an updated presentation and links to additional resources on saml.xml.org.

I'm not sure if any of this is going to help though, as your use case does not seem to be what SAML 2.0 is trying to do. You can add attributes and extensions as needed to requests and responses, but I can't see many identity providers doing anything with those attributes and responses.

Joeljoela answered 17/7, 2009 at 9:15 Comment(2)
What protects my application from processing self-made fake assertions about the user? While the the assertion is sended to the client as an xml form anybody is able to create a fake assertion. What kind of security checks should be done by my application to verify that the processed assertion is originaly sended by the identity provider?Dwinnell
The SAML schemas include very good support for both digital signature and encryption of any element that could be considered confidential or sensitive. Signatures are the easiest way to start ensuring that the delivered data is intact and authentic. The schemas also include support for validity periods, which you should check, and the supporting protocols discuss replay protection, which would help ensure security.Joeljoela

© 2022 - 2024 — McMap. All rights reserved.