OPNsense Forum

Archive => 15.7 Legacy Series => Topic started by: cdburgess75 on November 30, 2015, 06:26:44 am

Title: [SOLVED] Proxy LDAP auth issue
Post by: cdburgess75 on November 30, 2015, 06:26:44 am
I am having an issue getting squid to accept the credentials for AD users.  All my diagnostics are good with built in tools for opnsense.  LDAP connection is working fine.  But when I try to login I get an: squid: user 'dave' could not authenticate in the logs.  I see this in auth.inc and was wondering if maybe it is still work in progress:
---
function authenticate_user($username, $password, $authcfg = NULL) {

   if (empty($authcfg)) {
      $authName = 'Local Database';
   } else {
      $authName = $authcfg['name'];
      if ($authcfg['type'] == 'local') {
         // avoid gettext type issues on Local Database, authenticator should always be named "Local Database"
         $authName = 'Local Database';
      } elseif ($authcfg['type'] == 'ldap') {
         // temporary fix, ldap handler doesn't do this init yet.
         ldap_setup_caenv($authcfg);
      }
Title: Re: Proxy LDAP auth issue
Post by: franco on November 30, 2015, 07:35:24 am
The code is not a work in progress. When did you start working with squid/AD auth? 15.7.18 switched the authentication backend, but maybe there is a regression in conjunction with squid. Will report back soon. :)
Title: Re: Proxy LDAP auth issue
Post by: cdburgess75 on November 30, 2015, 10:13:24 pm
Awesome job by the way.  I love the firewall.  To answer you, I started trying to get this working (LDAP proxy auth) a few days ago.  I was able to import all the users and see all the container.  Ding checks out fine.  This appliance was upgraded from 15.7.1 to 15.7.20 prior to the attempt.  So we have the latest version now.  If there is anything I can do to help ket me know.   
Title: Re: Proxy LDAP auth issue
Post by: AdSchellevis on November 30, 2015, 10:30:38 pm
The proxy auth plugin only functions for the primary authentication option at the moment and tries to locate a local user role "user-proxy-auth" before doing the actual authentication (in src/etc/inc/squid.auth-user.php).

I think we should revise this a bit, it's probably better to make the authentication option selectable in the user interface and only use the local role for users in the local database.

We're using a similar option for the new captive portal already, let me try to squeeze this feature in here as well (somewhere this week).

Title: Re: Proxy LDAP auth issue
Post by: AdSchellevis on December 01, 2015, 08:18:00 pm
I just added our new pluggable authentication system to the squid auth plugin and changed the user interface to support the selection.
When installed, you can add one or multiple authentication servers to be used with the proxy.

This commit contains the new feature: https://github.com/opnsense/core/commit/58ab1e61e3a50c8e3ed7033c69d1d20d9754aa96


The new feature is backwards compatible, so I think we will add it to the next release.
Title: Re: Proxy LDAP auth issue
Post by: cdburgess75 on December 03, 2015, 02:09:48 pm
I will test this out tonight and reply. Thank you very much.
Title: Re: Proxy LDAP auth issue
Post by: cdburgess75 on December 04, 2015, 02:43:14 am
I edit the 3 files and restarted squid,  but did not have good results.  The problem I am having now is complete opposite.  Before I could not authenticate,  now the authentication pop up in the browser is not launching (as if maybe set to none or no authentication).  But I have both local database and the LDAP connection selected in the new gui interface.  Processes are running fine, my http request are logged fine as well.  However,  the syslog shows no attempt at authentication like before.  Hmmm :)
Title: Re: Proxy LDAP auth issue
Post by: AdSchellevis on December 04, 2015, 09:01:45 am
sorry about that, forgot to change the template to accept the different setting...
This commit should fix the issue: https://github.com/opnsense/core/commit/e34dd6a60b291627e8cabc090924d5f2ce37b6b7


It worked when nothing was changed (only local), but as soon as you started using the feature it didn't match any more ;)
Title: Re: Proxy LDAP auth issue
Post by: franco on December 04, 2015, 05:52:38 pm
Both changes are on opnsense-devel 15.7.99_1623 (15.7.21 development) so they can be easily tested.

https://forum.opnsense.org/index.php?topic=917.0
Title: Re: Proxy LDAP auth issue
Post by: cdburgess75 on December 07, 2015, 04:06:03 pm
thank you so much.  I will check this out in 2 days and report back.
Title: Re: Proxy LDAP auth issue
Post by: cdburgess75 on December 15, 2015, 01:02:18 am
I went ahead and started with a fresh copy of OPNsense 15.7.22-amd64.  I configured LDAP successfully and diag tested out fine.  All the same steps as before.  Enabling squid, etc.  However,  I cannot get a popup asking for me to authenticate.  All traffic is passing through squid according to the logs.  Also,  It allows normal traffic without the proxy.  Not sure whats going on,  is there anything I can help with?
Title: Re: Proxy LDAP auth issue
Post by: AdSchellevis on December 15, 2015, 08:34:24 am
Can you check if the auth application is inserted into your config?

in /usr/local/etc/squid/squid.conf

there should be a blob of data like this:
Code: [Select]
auth_param basic program /usr/local/etc/inc/squid.auth-user.php
auth_param basic realm OPNsense proxy authentication
auth_param basic credentialsttl 2 hours
auth_param basic children 5
# ACL - Local Authorized Users - local_auth
acl local_auth proxy_auth REQUIRED

If it is, do you have any access control lists defined.
Title: Re: Proxy LDAP auth issue
Post by: cdburgess75 on December 16, 2015, 10:35:04 pm
Yes,  I checked: the auth app is inserted like that word for word.  Also,  I have not defined any ACL's yet.
Title: Re: Proxy LDAP auth issue
Post by: AdSchellevis on December 17, 2015, 08:36:57 am
Oops, missed a line in my previous commit:
https://github.com/opnsense/core/commit/e96aa187c869b5d756d5a659f63734fee4dc7799

When authentication other then local is selected, it didn't link the acl. sorry about that.
Title: Re: Proxy LDAP auth issue
Post by: cdburgess75 on December 18, 2015, 11:08:41 pm
ok,  I tried it again.  We are still not able to auth to the confirmed ldap connection.  We see in the logs that it is trying:
Dec 18 23:04:21   squid: user 'dave' could not authenticate.
Dec 18 23:04:21   squid: user 'dave' could not authenticate.
Dec 18 23:04:11   squid: user 'test' could not authenticate.
Dec 18 23:04:11   squid: user 'test' could not authenticate.

It seems to only work on the local db.  The AD LDAP connection is working and allows us to add users.  I also gave the permission "proxy login" to a group and added them to that in the users section.
Title: Re: Proxy LDAP auth issue
Post by: AdSchellevis on December 19, 2015, 10:00:43 am
Ok, my test box only had local available, just tested with ldap and found the issue for this one.... a typo in the local fall-back mechanism. 

Commit https://github.com/opnsense/core/commit/187d7ee09fa7403a8d513e21a430c2cb36180f59 should fix this one for good.


Title: Re: Proxy LDAP auth issue
Post by: franco on December 22, 2015, 08:26:21 am
Will all be in 15.7.23 available later today. Last time's the charm, huh? :)
Title: Re: Proxy LDAP auth issue
Post by: cdburgess75 on December 23, 2015, 06:01:46 pm
:)  I am going to give it a shot,  Ill report back.
Title: Re: Proxy LDAP auth issue
Post by: cdburgess75 on December 23, 2015, 06:26:22 pm
Yes,  I upgraded to 15.7.23-amd64 and it worked!  thank you so much for your hard work!   
Title: Re: Proxy LDAP auth issue
Post by: AdSchellevis on December 23, 2015, 07:24:15 pm
your welcome, thanks for your feedback.