dotnet / dotnet/Kerberos.NET

Gtting 401 error with client generated Kerbeors token added to .net 7 httpclient

Open
#361 31 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
567
Forks
109
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
cannot get token to authenticate

**To Reproduce**
.net 7 app Using httpclient with UserDeaultCredentials set to falue

var client = ClientFactory.CreateClient("SuperAssociate");
HttpContent inputContent = new StringContent(GetEvent(), System.Text.Encoding.UTF8, "application/json");

DnsQuery.RegisterImplementation(new PlatformIndependentDnsClient());

var kClient = new KerberosClient();
var kerbCred = new KerberosPasswordCredential("XXXXXX", "YYYYYYY", "salelytics.local");

await kClient.Authenticate(kerbCred);

var ticket = await kClient.GetServiceTicket("host/webtest01.salelytics.local");

var apiHost = "http://webtest01.salelytics.local/";
Guard.Against.NullOrEmpty(apiHost);

client.BaseAddress = new Uri(apiHost);
var apiSite = "SuperAssociateRuss/api/IncomingEvent/";

client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Negotiate", Convert.ToBase64String(ticket.EncodeGssApi().ToArray()));

var apiResponse = await client.PostAsync(apiSite, inputContent);

**Expected behavior**
The Authorization Header should validate as my user

The token I get from Kerbeoros.Net is different from the one my chrome browser is sending. should it be the same?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.