Unauthorized with NTLM auth

Hi, I just tried. It returns 401:(

Is it the same syntax?

AFAIK, but here the http-debug should … not work for the authorization :frowning: so we can’t even see what goes wrong :frowning: .
Well I am out of ideas, sorry

Thanks for following up anyway.

Is it any way to specify the domain explicitly? I cant seem to find out how.

Given this lines from the lib k6 is using I think https://kingdom\\george:1234321@somewhere.org will mean user george of domain kingdom with password 1234321.

Haven’t tried it though :wink:

yeah, read that. It doesn’t work though…
ERRO[0001] GoError: parse http://mydummydomain\maskeduser:maskedpw@maskedsite.com net/url: invalid userinfo

and

ERRO[0001] GoError: parse http://mydummydomain\\\maskeduser:maskedpw@maskedsite.com net/url: invalid userinfo

@niklasbae Does the output with --http-debug change ?

No, that output is with —http-debug=«full»

Given the error, it seems like you might need to escape the backslash in the username? Try something like http://mydummydomain%5Cmaskeduser:maskedpw@maskedsite.com, though reading the code @mstoykov linked, I’m not sure if that would help :disappointed:

Unfortunately no luck…

Im very curious if it is the cookie between the second and third authentication request that breaks the deal… how difficult is it for you guys to create a hotfix for saving the cookie that should be set by set-cookie here?

I think it’s likely to be fairly difficult, because of the way that NTLM authentication library is structured. It may require substantial refactoring of how we make HTTP requests and likely also forking that library or using another one or rolling our own… If the cookie handling is even the root cause of the issue - I’m still not convinced that’s the case. And in either case, as @mstoykov mentioned, due to the scarcity of publicly accessible NTLM endpoints, first we’d need to set up some test environment, so we can reproduce and investigate the issue…

Hi, is this issue fixed in k6 now?

import http from 'k6/http';
import { check, sleep } from 'k6';
export default function ()

 {
const username = `username%2Fdomain`;
const password = 'password';

 const credentials = `${username}:${password}`;

  const res = http.get(`http://${credentials}@localhost/github.com`, { auth: 'ntlm'});

  check(res, {

        "status was 200": (res) => res.status == 200

      });

    
      sleep(1);  

      console.log(res.status);

      console.log(res.body);

      console.log(res.json());

      console.log(res.status);

 }

The return 401 error:
This error occurs when either the username or password supplied to IIS is invalid, or when IIS cannot use the username and password to authenticate the user.

K6 version: 0.25.1

this bug not fixed on this version, right?

Hi @lambda999 and @huligesh.hanumanthap, very sorry for the very late reply @huligesh.hanumanthap .

There isn’t really any development here. Again NTLM is deprecated by Microsoft (for years now), the support for it is in practice none existent apart from Microsoft products. I couldn’t even make a server that uses it - this probably is because almost anything that had support at some point has dropped it. Making an IIS server with NTLM requires some amount of professional licenses and none on the k6 team even uses Windows or has used IIS.

We have update the library so it’s possible that this has been fixed, but we can’t really confirm this :person_shrugging: .

The return 401 error:
This error occurs when either the username or password supplied to IIS is invalid, or when IIS cannot use the username and password to authenticate the user.

This is more or less what should happen though. 401 means that it isn’t authenticated. If you provide none authenticated credentials (wrong user/password) it should return exactly this.

1 Like

Hello, mstoykov, thank you for your reply, :blush:

I’m confused,

For the error I mentioned, “this error occurs when the user name or password provided to IIS is invalid, or when IIS cannot authenticate the user with the user name and password.” I ‘m sure that the user name and password are correct,(Note: Because with the Postman tool with NTLM auth will return 200 code).
In addition. just as you say, "Making an IIS server with NTLM requires some amount of professional licenses and none on the k6 team even uses Windows or has used IIS.’ so actually, k6 will not support this authentication anymore, right?

” I ‘m sure that the user name and password are correct,

Then this is likely this problem - you can try the latest version of k6. As I said the library we use has been updated a couple of times it is possible that the latest version has just fixed it and we haven’t noticed - as we can’t test.

so actually, k6 will not support this authentication anymore, right?

This hasn’t been decided, but it’s not out of the question that we decide to drop it given that supporting it is turning out to be a problem and we can’t even diagnose issues. But again - no such decision has been made so :person_shrugging:

I got it, I will try the latest version of k6(Note: where could I get the latest k6 package), thanks a lot.
0.37.0 is the latest version, right?

I would recommend following the Installation instructions that are for your case and yes v0.37.0 is the currently the latest release. On its release page there are also downloadable packages for some platforms.

1 Like

Hi mstoykov,
The return code is 401 error code when I try to send POST API request with NTLM auth, I am not sure whether the Authorization is not right, as below picture, can you help me, how to correctly with the NTLM auth with post request, thanks. (Note: the password and username is right, and the get request could request success and return 200 code)

Regards
Lambda

Given the provided screenshot you are setting auth as a header instead of as part of the Params object. For that it need to be in the object outside so

http.post(
url,
body,
{ 
  headers: {
    accept: "something", 
    ... other headers...
    "sec-ch-ua-platform": "Windows", 
  },
  auth: "ntlm",
});

Hope this helps you

1 Like

Thanks mstoykov,

thanks for you correct my wrong. now everything is well. :hugs: