As you can see, the built-in .NET support for the SAML2 protocol is not supported, although SAML2 tokens are supported.
Instead of doing it yourself, I suggest you familiarize yourself with the available source and commercial libraries for SAML2P for ASP.NET. There is a lot of work to create a reliable service provider in addition to what is offered in the .NET framework. (I know, because I built it, and if I knew that I knew now, I donβt think I will do it again).
If you decide to go ahead, Saml2SecurityTokenHandler contains an important tool for reading claims from XML, converting them into claim identifiers, and verifying approval signatures. Note that the handler expects claims to be signed - there AFAIK is not built-in to support handling the case when the entire SAML response has been signed (which also covers the built-in claims).
Using Kentor.AuthServices
The script described here directly uses the Kentor.AuthServices API, which is an advanced script that is not recommended as a first choice. For web APIs and modern MVC applications, it is much better to use the Owin middleware from Kentor.AuthServices.Owin.
This code uses the APIs from Kentor.AuthServices.HttpModule.
Config
To use AuthServices API directly, you will first need to create a configuration as described in docs . This can be done both in code and in web.config. In this example, I simply refer to the Options property, which is an instance of IOptions . It can be downloaded from web.config via the Options.FromConfiguration property.
Submit AuthnRequest
The first step for authentication is to send AuthnRequest. dummyUrl is any non-zero Uri object. It will not be used in this scenario, but cannot be empty.
var idp = Options.IdentityProviders.Default; var urls = new AuthServicesUrls(fullUrlOfYourAcsService, dummyUrl, applicationUrl); var authnRequest = idp.CreateAuthenticateRequest(dummyUrl, urls);
Even the OP has already managed to do this, it must be done through AuthServices to correctly register the pending request, which is then mapped to the returned response.
Receive Response
The next step is to get the returned SAML2Response response. This code must be in the location "fullUrlOfYourAcsService" specified when sending AuthnRequest.
var result = CommandFactory.GetCommand(CommandFactory.AcsCommandName) .Run(new HttpRequestWrapper(HttpContext.Current.Response), Options);