Bonjour,
J’ai mis en place cela dans la société pour laquelle je travaille actuellement, l’authentification directement sur un AD Microsoft est une vraie plaie à faire fonctionner, honnêtement il est probablement plus simple de mettre en place un OpenLDAP synchro avec l’AD et que le Squid aille faire l’authentification sur l’OpenLDAP et non l’AD.
Ceci étant dit, voilà la procédure que j’ai appliqué, directement tiré de notre Wiki (désolé, c’est un peu sous forme brute, par ailleurs notez que j’ai expurgé toutes les infos relatives à la société, adresses IP, hostnames & domaine notamment) :
= Configuration=
== Authentification AD ==
- Ajouter les contrôleurs de domaine au fichier ‘’’/etc/hosts’’’ :
IP_Adress DC_FQDN DC_SHORTNAME
IP_Adress DC_FQDN DC_SHORTNAME
- Installer les packages suivants :
apt-get install krb5-user krb5-config samba-common samba winbind
- Configuration de Kerberos (fichier ‘’’/etc/kerberos/krb5.conf’’’) :
[libdefaults]
default_realm = DOMAIN.TLD
ticket_lifetime = 24000
dns_lookup_realm = false
dns_lookup_kdc = false
default_keytab_name = /etc/squid3/PROXY.keytab
; for Windows 2003
; default_tgs_enctypes = rc4-hmac des-cbc-crc des-cbc-md5
; default_tkt_enctypes = rc4-hmac des-cbc-crc des-cbc-md5
; permitted_enctypes = rc4-hmac des-cbc-crc des-cbc-md5
; for Windows 2008 with AES
default_tgs_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5
default_tkt_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5
permitted_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5
[realms]
DOMAIN.TLD = {
kdc = DC_FQDN
kdc = DC_FQDN
admin_server = DC_FQDN
admin_server = DC_FQDN
default_domain = DOMAIN.TLD
}
[domain_realm]
.DOMAIN.TLD = DOMAIN.TLD
DOMAIN.TLD = DOMAIN.TLD
[login]
krb4_convert = true
krb4_get_tickets = false
[logging]
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmin.log
default = FILE:/var/log/krb5lib.log
=== Installation de mskutil ===
-
Télécharger mskutil sur http://sourceforge.net/projects/msktutil/
-
Installer les prérequis :
apt-get install build-essential libkrb5-dev libldap2-dev libsasl2-dev
-
Installer mskutil
./configure
make
make install
-
Initialiser une session Kerberos pour intégrer le serveur au domaine :
root@proxy:~# ‘’‘kinit DC_USER’’‘
Password for DC_USER@DOMAIN.TLD:
root@proxy:~# ‘’‘klist’’'
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: DC_USER@DOMAIN.TLD
Valid starting Expires Service principal
17/08/2015 15:33:19 17/08/2015 22:13:13 krbtgt/DOMAIN.TLD@DOMAIN.TLD
-
Configuration de Samba (fichier ‘’’/etc/samba/smb.conf’’’) :
[global]
realm = DOMAIN.TLD
workgroup = WORKGROUP
netbios name = proxy
password server = dc-act-01 dc-act-02
server string = %h server
security = ads
#allow trusted domains = Yes
winbind uid = 300000-400000
winbind gid = 300000-400000
winbind enum users = Yes
winbind enum groups = Yes
winbind use default domain = Yes
winbind refresh tickets = Yes
winbind nested groups = Yes
winbind separator = +
idmap uid = 300000-400000
idmap gid = 300000-400000
idmap config WORKGROUP : backend = rid
idmap config WORKGROUP : base_rid = 2000
idmap config WORKGROUP : range= 2000-299999
template shell = /bin/bash
template homedir = /home/%U
idmap cache time = 1
idmap negative cache time = 1
winbind cache time = 1
load printers = no
domain master = no
preferred master = no
domain logons = no
wins support = no
wins proxy = no
dns proxy = no
[homes]
comment = MySquid Home
browseable = no
writable = yes
read only = no
create mask = 0664
directory mask = 0775
-
Configuration du fichier ‘’’/etc/nsswitch.conf’’’ :
/etc/nsswitch.conf
Example configuration of GNU Name Service Switch functionality.
If you have the glibc-doc-reference' and
info’ packages installed, try:
`info libc “Name Service Switch”’ for information about this file.
passwd: compat winbind
group: compat winbind
shadow: compat
gshadow: files
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
-
Arrêter smbd et winbind :
systemctl stop smbd && systemctl stop winbind
-
Ajouter le serveur au domaine :
’’‘net ads dns register -S DC_IP_Adress -P’’’
’’‘net ads join -S dc-act-01 -U DC_USER’’‘
Enter DC_USER’s password:
Using short domain name – DOMAIN
Joined ‘proxy’ to dns domain ‘DOMAIN.TLD’
DNS Update for proxy.DOMAIN.TLD failed: ERROR_DNS_GSS_ERROR
DNS update failed: NT_STATUS_UNSUCCESSFUL
’’‘net rpc getsid -S DOMAIN -I DC_IP_Adress -U DC_USER’’’
-
Redémarrer smbd et swinbind :
systemctl start smbd && systemctl start winbind
-
Vérifier l’intégration au domaine :
’’‘net ads info’’‘
LDAP server: DC_IP_Adress
LDAP server name: DC_FQDN
Realm: DOMAIN.TLD
Bind Path: dc=DOMAIN,dc=TLD
LDAP port: 389
Server time: lun., 17 août 2015 16:39:59 CEST
KDC server: DC_IP_Adress
Server time offset: 0
’’‘net ads testjoin’’‘
Join is OK
’’‘wbinfo -t’’'
checking the trust secret for domain DOMAIN via RPC calls succeeded
-
Ajouter l’utilisateur ‘’‘proxy’’’ au groupe ‘’‘winbindd_priv’’’ :
’’‘usermod -a -G winbindd_priv proxy’’’
=== Negotiate_wrapper ===
=== Configuration de /etc/squid3/squid.conf ===
- Ajouter les lignes suivantes :
Include authentification configuration file
include /etc/squid3/host_specific_conf/auth.conf
ldap authorisation
external_acl_type memberof %LOGIN /usr/lib/squid3/ext_ldap_group_acl -R -K -S -b “dc=DOMAIN,dc=TLD” -D Admin_squid@DOMAIN.TLD -W /etc/squid3/ldappass.txt -f “(&(objectclass=person)(sAMAccountName=%v)(memberof=cn=%g,ou=Groupe,ou=Groupe,dc=DOMAIN,dc=TLD))” -h DC_FQDN
- Créer le fichier ‘’’/etc/squid3/host_specific_conf/auth.conf’’’ avec le contenu suivant (penser à adapter en fonction du nom du proxy) :
negotiate kerberos and ntlm authentication
auth_param negotiate program /usr/local/bin/negotiate_wrapper -d --ntlm /usr/bin/ntlm_auth --diagnostics --helper-protocol=squid-2.5-ntlmssp --domain=DOMAIN --kerberos /usr/lib/squid3/negotiate_kerberos_auth -s HTTP/proxy.DOMAIN.TLD@DOMAIN.TLD
auth_param negotiate children 20 startup=0 idle=1
auth_param negotiate keep_alive off
provide basic authentication via ldap for clients not authenticated via kerberos/ntlm
auth_param basic program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-basic --domain=DOMAIN
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
- Recharger la configuration de Squid3 :
systemctl reload squid3.service
=== Utilisation dans les ACL ===
ACL for proxy auth and ldap authorizations
acl auth proxy_auth REQUIRED
ACL for matching to Active Directory groups
aclname acltype typename activedirectorygroup
acl FullAccess external memberof "/etc/squid3/ADgroups/fullaccess.txt"
acl RestrictedAccess external memberof "/etc/squid3/ADgroups/restricted.txt"
acl ConseillerAccess external memberof “/etc/squid3/ADgroups/conseiller.txt”
################## NEW ACCESS RULES ##################
http_access rules
http_access deny block_canalsat
http_access allow FullAccess Whitelist_NoAuth
enforce authentication, order of rules is important for authorization levels
http_access deny !auth
Full Access
http_access allow FullAccess auth
First batch of blacklists
http_access deny adultsites
http_access deny astrosites
http_access deny audio_videosites
http_access deny datingsites
http_access deny filehostingsites
http_access deny forumsites
http_access deny illegalsites
http_access deny jeuxsites
http_access deny mobile_phonesites
http_access deny radiosites
http_access deny redirecteursites
http_access deny shoppingsites
http_access deny updatessites
http_access deny vodEurosportsites
http_access deny warezsites
http_access deny webmailsites
Restricted Access
http_access allow RestrictedAccess auth
Second batch of blacklists
http_access deny deezer
http_access deny apple
http_access deny facebook
http_access deny youtube
http_access deny msn1
http_access deny msn2
http_access deny msn3
http_access deny msn4
http_access deny runonce
http_access deny google_video
http_access deny google_cache
http_access deny StreamingRequest1 all
http_access deny StreamingRequest2 all
http_access deny StreamingRequest3 all
http_access deny StreamingRequest4 all
http_reply_access deny StreamingReply1 all
http_reply_access deny StreamingReply2 all
http_reply_access deny StreamingReply3 all
http_reply_access deny StreamingReply4 all
Teleconseillers access
http_access allow ConseillerAccess auth
################# NEW ACCESS RULES ##################