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

NTLM authentication is not working. Possibly missing set TargetPreffredAuthSchemes #329

Closed
abhigogna opened this issue Aug 15, 2016 · 10 comments

Comments

@abhigogna
Copy link

When I try to use NTLM-Auth, I get the following error message:
"WARNING: NEGOTIATE authentication error: Invalid name provided (Mechanism level: KrbException: Cannot locate default realm)"

I think it could be because:

  1. Kerberos switching to NTLM. Since the Authscope takes 3 args of nil -1 nil here, which probably does not let the realm switch/fallback happen from kerbros to NTLM. Per Apache documentation, we need another nil doc

  2. We may have to pass in a set of target preferred auth schemes to the request.
    RequestConfig config = RequestConfig.custom().setTargetPreferredAuthSchemes(Arrays.asList(AuthSchemes.NTLM)).build();

Unfortunately, I am still learning clojure and do not know how to make these changes but if someone can provide a fix, I will be willing to test it out.

@dakrone
Copy link
Owner

dakrone commented Aug 15, 2016

Thanks for digging into the issue @abhigogna, do you happen to know how I can test a change locally with NTLM auth?

@abhigogna
Copy link
Author

To test this locally is painful, unless you have an active directory setup on a windows box. Here is the setup I know of:

  1. Setup Microsoft Active Directory. This part is little tedious.
  2. Create a small asp.net project that authenticates with AD. This part is simple you just need to select <authentication mode="Windows"> in web.config file.

If you don't have one available, there is Microsoft Azure cloud service that is free with $200 worth of cloud credit. We can create one over there.

@abhigogna
Copy link
Author

@dakrone -If you can push your changes to a branch, I can verify it at work.

@dakrone
Copy link
Owner

dakrone commented Aug 17, 2016

@abhigogna that would be great, I'll let you know when I (or someone else) gets a chance to push a change for this!

@abhigogna
Copy link
Author

abhigogna commented Aug 27, 2016

Dakrone,

Here is the working java code using Apache Client 4.5 lib. This code does not use any deprecated methods/classes. Hope it is useful in modelling clojure wrapper.

    public static HttpClient getClient(){

        PoolingHttpClientConnectionManager connPool =
                new PoolingHttpClientConnectionManager();

        connPool.setMaxTotal(50);
        connPool.setDefaultMaxPerRoute(5);

        // Authentication
        CredentialsProvider credsProvider = new BasicCredentialsProvider();
        credsProvider.setCredentials(AuthScope.ANY,
                new NTCredentials("user", "password", "localhost", "corp"));

        CloseableHttpClient httpClient = HttpClients.custom()
                .setConnectionManager(connPool)
                .setDefaultCredentialsProvider(credsProvider)
                .build();

        return httpClient;
    }

@MageMasher
Copy link

Hi there @dakrone , I know this is about a year old but I was wondering if there was any movement or resolution to this issue? I saw there is a pr #198 out there from @ckarlsen84 which implements the NTLM Auth but it has merge conflicts now. Is there anything I can do to help move this change into master? If I fixed the merge conflicts would you accept them?

@MageMasher
Copy link

Oh, actually I just saw pr #255 which appears to resolve this. All the google links point to this pr so I just want to leave this note here for anyone who comes along after me. Thanks for having such a great library!

@dakrone
Copy link
Owner

dakrone commented Sep 19, 2017

@MageMasher thanks for checking that this resolves this. I'm going to close this for now and we can reopen if it isn't resolved by #255

@dakrone dakrone closed this as completed Sep 19, 2017
@MageMasher
Copy link

MageMasher commented Sep 19, 2017 via email

@dakrone dakrone mentioned this issue Sep 26, 2017
@MageMasher
Copy link

@dakrone Can confirm, using

(client/get url {:ntlm-auth ["<my-user>" "<my-pass>" "<my-host>" "<my-domain>"]})

successfully authenticates. Thanks for an awesome library!

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

No branches or pull requests

3 participants