Here is my current situation. I have an ADFS 2.0 server set up, with two RP web applications connected to it. These applications, App1 and App2, are Web Applications with a Web API backend. Javascript AJAX calls are used.
From my initial understanding of WIF, I thought I could login through the browser and then have access to both applications. This proved incorrect, as I cannot call the Web API functions of App2 from App1. The only way that I can do this is by typing in the URL to App2, only then will my subsequent calls from App 1 work (The correct FedAuth cookie is passed in the header)
So I've been searching and searching for ways to actually call App2's web API from App1, but I've come up empty handed. The closest thing I've got to a solution is (I believe) by adding a message handler, as in this example
If I understand this correctly, I should be able to make WebAPI receive my SAML2 security token.
My code is as follow:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
var authentication = CreateAuthenticationConfiguration();
config.MessageHandlers.Add(new AuthenticationHandler(authentication));
}
}
private static AuthenticationConfiguration CreateAuthenticationConfiguration()
{
System.Diagnostics.Debugger.Break();
var authentication = new AuthenticationConfiguration
{
ClaimsAuthenticationManager = new MyClaimsAuthenticationManager(),
EnableSessionToken = true,
RequireSsl = false
};
authentication.AddSaml2(
issuerThumbprint: **Hidden**,
issuerName: "https://192.168.0.55/adfs/ls/",
audienceUri: "http://localhost/MyCompany.App2/",
certificateValidator: X509CertificateValidator.None,
options: AuthenticationOptions.ForAuthorizationHeader("AdfsSaml"),
scheme: AuthenticationScheme.SchemeOnly("AdfsSaml"));
return authentication;
}
The calls reach MyClaimsAuthenticationManager.Authenticate(), however the IncomingPrincipal is still not authenticated. I have no way to know whether or not it receives a SAML2 token, since I can't debug anything before MyClaimsAuthenticationManager.Authenticate()
My questions:
1) Is it possible to call my App2 Web API functions despite being authenticated in App1? (They use the same ADFS)
2) If it is possible, am I ont the right track using a ThinkTecture AuthenticationHandler?
Thank you.