Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RussKahler1970 opened this issue Dec 1, 2023 · 31 comments
Labels

Comments

@RussKahler1970
Copy link

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?

@SteveSyfuhs
Copy link
Collaborator

SteveSyfuhs commented Dec 1, 2023 via email

@RussKahler1970
Copy link
Author

I changed the site to only allow Kerberos so Chrome is only using Kerberos.

Here are the two tokens:
Token from Chrome
Authorization: Negotiate YIIUQQYGKwYBBQUCoIIUNTCCFDGgMDAuBgkqhkiC9xIBAgIGCSqGSIb3EgECAgYKKwYBBAGCNwICHgYKKwYBBAGCNwICCqKCE/sEghP3YIIT8wYJKoZIhvcSAQICAQBughPiMIIT3qADAgEFoQMCAQ6iBwMFACAAAACjghH5YYIR9TCCEfG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atyDZHSHDkKwNGDzvmFv6qERJk+Zkf5rNIVnU3+QUCB9zP5EKezV4h7vn1v12OmdjQ==

@RussKahler1970
Copy link
Author

Sorry, I failed to add that the Kerberos.net user and windows user for Chrome are the same.

@RussKahler1970
Copy link
Author

Its highly possible I have something wrong elsewhere. do you know how to get more info on why it failed? what tool can I use to trace the failed Authentication in windows/IIS?

@SteveSyfuhs
Copy link
Collaborator

Alright, let's see:

Chrome:

image

Kerberos.NET

image

There's a noticeable difference in the structure because the top-level structures are encoded differently. You can see the differences in the bold headers. I also noticed the tool (bruce kdecode) took an extra second to process it, meaning it was searching for the structure in the blob. That would suggest the output is encoded wrong. Maybe there is a bug in Kerberos.NET.

@RussKahler1970
Copy link
Author

the SNAME is different too:
for Chrome is HTTP/webtest01.salelytics.local
for Kerberos.Net its host/webtest01.salelytics.local

Should I use http/webtest01.salelytics.local when I get the ticket?

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

@RussKahler1970
Copy link
Author

I am using this to encode the ticket. Is that right for windows IIS?
Convert.ToBase64String(ticket.EncodeGssApi().ToArray())

@SteveSyfuhs
Copy link
Collaborator

Okay, the difference in decoding is a bug in Bruce itself, not the library.

image

This shows it's decoding correctly.

the SNAME is different too:
for Chrome is HTTP/webtest01.salelytics.local
for Kerberos.Net its host/webtest01.salelytics.local

This is a good candidate for testing next. HTTP is an alias for HOST in Windows, but if you have an explicit HTTP SPN registration that will take priority.

Convert.ToBase64String(ticket.EncodeGssApi().ToArray())

Is fine.

@wfurt
Copy link
Member

wfurt commented Dec 1, 2023

Note that the Negotiate protocol has its own ASN1 structure e.g. it is more that just a ticket. Does Kerberos.Net implement RFC 4559?

and the name is different e.g. HTTP vs host. That is essentially different SPN, right?

@SteveSyfuhs
Copy link
Collaborator

That's what EncodeGssApi does. Poorly named, but does the business correctly.

public ReadOnlyMemory<byte> EncodeGssApi()
{
    var token = GssApiToken.Encode(Kerberos5Oid, this);

    var negoToken = new NegotiationToken
    {
        InitialToken = new NegTokenInit
        {
            MechTypes = new[] { Kerberos5Oid },
            MechToken = token
        }
    };

    return GssApiToken.Encode(SPNegoOid, negoToken);
}

@SteveSyfuhs
Copy link
Collaborator

Although... the KVNO on both the chrome and kerb.net tickets are the same, which given that it's non-zero would suggest they're the same service principal too.

Are you seeing anything on the web server side in the event logs indicating why it's failing?

@RussKahler1970
Copy link
Author

I see this in the iis log.
2023-12-01 17:24:45 10.43.128.151 POST /SuperAssociateRuss/api/IncomingEvent/ - 80 - 10.43.242.148 - - 401 1 2148074248 2617

I don't see anything in Event Viewer at this tine. I can do more search on the server.

@RussKahler1970
Copy link
Author

One other note on this. the Kerberos ticket generated with chrome works and validates. The site in question requires windows authentication and only has Negotiate as the only provider.

@RussKahler1970
Copy link
Author

I tried http/webtest01.salelytics.local and it failed too.

@wfurt
Copy link
Member

wfurt commented Dec 1, 2023

BTW is there reason why you use Kerberos.net primitives instead of HttpClient directly - just curious.

@RussKahler1970
Copy link
Author

well the end goal is for this to run in a linux container that is not joined to our domain. I was hoping to use Kerberos.Net to get a kerberos token and use it for authentication to a site that requires windows authentication. my containers will be running in AWS Fargate/ECS serverless environmennt in a vpc that is connected to our domain.

@SteveSyfuhs
Copy link
Collaborator

Okay, I see what the problem might be. This is interesting.

The chrome message is decoding with OIDs
1.3.6.1.5.5.2 -- SPNEGO
1.2.840.113554.1.2.2 -- Kerberos

And the Kerberos.NET message is decoding as
1.3.6.1.5.5.2 -- SPNEGO
1.3.6.1.5.2 -- Kerberos

Which is abnormal because 1.3.6.1.5.2 is not supposed to be an OID Kerberos.NET understands. We should be using 1.2.840.113554.1.2.2.

But we aren't because of this change: https://github.com/dotnet/Kerberos.NET/blame/7be209d7549417cf0d4fdd178266417c39cc7efe/Kerberos.NET/Entities/MechType.cs#L15

Oops. That's just wrong one way or another so it needs to be fixed anyway, so let's see if this fixes it.

@RussKahler1970
Copy link
Author

the .Net 7 is not working to build a credential cache for the user either.

@RussKahler1970
Copy link
Author

Is there a way to get pull or build that I could test? I am currently using the nuget package form nuget.org

@SteveSyfuhs
Copy link
Collaborator

Yeah, I'm going to push up a prelease package.

@SteveSyfuhs SteveSyfuhs mentioned this issue Dec 1, 2023
4 tasks
@RussKahler1970
Copy link
Author

sweet lust let me know when it up there I can download and test it out.

@SteveSyfuhs
Copy link
Collaborator

Hot off the press: https://www.nuget.org/packages/Kerberos.NET/4.6.48-gbe643a489a

It'll take a minute to index.

@RussKahler1970
Copy link
Author

Sweet first test but I got back 200!!!!
thanks for the quick response on this. I will do more testing from here..

@SteveSyfuhs
Copy link
Collaborator

I've merged that fix. I don't expect you'll see any other issues related to this in particular. I'll get a proper release of the package out this weekend or early next week once I've figured out how to get a proper test on this.

@RussKahler1970
Copy link
Author

Thanks for all your help on this.

@RussKahler1970
Copy link
Author

Is there someplace I can go to get more info on this package? How best to use it for high volume of calls using Kerberos tickets, cache, refreshing, etc.

@SteveSyfuhs
Copy link
Collaborator

Here's as good a place as any, though in a separate issue preferably. There isn't much in the way of one-size-fits-all guidance especially because if you're using this library it's likely for reasons that don't normally fit the usage of other libraries like the standard GSS libraries.

@RussKahler1970
Copy link
Author

RussKahler1970 commented Dec 4, 2023 via email

@SteveSyfuhs
Copy link
Collaborator

Just create an issue and put a label on it as a question.

@DanielMGoldberg
Copy link

Hi!
I have a similar issue, I'm currently getting 401 whenever I set use defaultcredentials to false.

For now I'm using a keytab and use the authenticate function in order to get a valid token, whenever I try to use it in order to access a third party api I'm getting the mentioned error 401.

Thanks

@SteveSyfuhs
Copy link
Collaborator

SteveSyfuhs commented Jun 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants