Skip to content

Commit

Permalink
Document how to use a custom authentication header e.g Kerberos (#3519)
Browse files Browse the repository at this point in the history
* Document how to subclass the HttpConnection to provide authentication headers, e.g for Kerberos

* move comment about examples to the top
  • Loading branch information
Mpdreamz committed Jan 25, 2019
1 parent 2a6d098 commit a98bcc3
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
using Tests.Core.Extensions;
using Tests.Domain;
using Tests.Framework;
#if DOTNETCORE
using System.Net.Http;
using System.Net.Http.Headers;
#endif

namespace Tests.ClientConcepts.Connection
{
Expand Down Expand Up @@ -117,6 +121,7 @@ public void InMemoryConnectionOverloadedCtor()
* By deriving from `HttpConnection`, it is possible to change the behaviour of the connection. The following
* provides some examples
*
*
* [[servicepoint-behaviour]]
* ===== ServicePoint behaviour
*
Expand Down Expand Up @@ -180,5 +185,30 @@ public void UseX509CertificateHttpConnection()
* See <<working-with-certificates, Working with certificates>> for further details.
*/
#endif
#if DOTNETCORE
/*
* [[kerberos-authentication]]
* ===== Kerberos Authentication
*
* For a lot of use cases subclassing HttpConnection is a great way to customize the http connection for your needs.
* E.g if you want to authenticate with Kerberos, creating a custom HttpConnection as followed allows you to set the right HTTP headers.
*
*
* TIP use something like https://www.nuget.org/packages/Kerberos.NET/ to fill in the actual blanks of this implementation
*/
public class KerberosConnection : HttpConnection
{
protected override HttpRequestMessage CreateRequestMessage(RequestData requestData)
{
var message = base.CreateRequestMessage(requestData);
var header = string.Empty;
message.Headers.Authorization = new AuthenticationHeaderValue("Negotiate", header);
return message;
}
}
#endif



}
}

0 comments on commit a98bcc3

Please sign in to comment.