Since day one it was possible to support multiple authentication methods with AuthenticationHandler (see here, here and here for some background). I simply stopped searching for other credentials once I found one of the registered ones. Since one of my clients also needed a feature to support multiple simultaneous authentication methods, I finally found the time to add this feature.
AuthenticationHandler will now search for all registered credential mappings and add each resulting claims identity to a claims principal. This allows for scenarios where you want to support e.g. SSL client certificates in addition to Basic Authentication – or in delegation style scenarios where you need to transmit two sets of credentials – the direct caller as well as the original client credentials.
After all identities have been hydrated from the registered credentials, you can also optionally run a claims authentication manager to normalize the multiple identities into a unified single identity again.
The server configuration could e.g. look like this:
authentication.AddBasicAuthentication(UserCredentials.Validate);
authentication.AddClientCertificate(ClientCertificateMode.ChainValidation);
…and the corresponding client:
var handler = new WebRequestHandler();
handler.ClientCertificates.Add(
X509.CurrentUser.My.SubjectDistinguishedName.Find("CN=Client").First());
var client = new HttpClient(handler) {
BaseAddress = _baseAddress
};
client.SetBasicAuthentication("bob", "bob");
The resulting ClaimsPrincipal will then hold two identities, one containing claims for the Basic Authentication (name) and one containing claims for the client certificate (thumbprint, common name, serial number, public key, etc…)
The sample can be found here. Nuget will be updated soon.
HTH