Задача - прикрутить squid к radius серверу, но не просто аутентификацию, а и использовать группы которые созданы в daloradius.
Для начала проверим работает ли наш радиус
если все ок, то проверим работоспособность модуля аутентификации на радиус сервере
вводим логин пароль уже созданного пользователя
Создадим скрипт на Perl который будет проверять принадлежность пользователя к группе.
#!/usr/bin/perl -w
# Disable output buffering
$|=1;
use DBI;
#use Log::Any qw($log);
#use Log::Any::Adapter ('File', '/var/log/perl_sq.log');
my $host = "127.0.0.1";
my $port = "3306";
my $dbuser = "radius";
my $pass = "Password";
my $db = "radius";
my $tbl = "radusergroup";
my $dsn = "DBI:mysql:database=$db;host=$host;port=$port";
my $key = "0";
while (<STDIN>){
chop;
($user, $group) = split(/\s+/);
# $log->info("user - $user");
# $log->info("group - $group");
if ((defined $user) && (defined $group))
{
$key = "0";
$dbh = DBI->connect($dsn, $dbuser, $pass);
$query = "select groupname from $tbl WHERE username = '$user'";
$sth = $dbh->prepare($query);
$sth->execute;
while(my @row = $sth->fetchrow_array) {
if ( "@row" eq "$group" )
{
print "OK\n";
$key = "1";
}
}
$sth->finish;
$dbh->disconnect();
}
if ( "$key" != "1" )
{
print "ERR\n";
}
}
Конфа сквида
visible_hostname SQUID-Atlant
auth_param basic program /usr/lib/squid3/basic_radius_auth -h 127.0.0.1 -w testing123
auth_param basic children 5
auth_param basic realm Atlant-Web-Proxy
auth_param basic credentialsttl 5 minute
auth_param basic casesensitive off
acl SSL_ports port 443
acl SSL_ports port 563 # snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 20 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl CONNECT method CONNECT
acl manager proto cache_object
external_acl_type perl_group %LOGIN /etc/squid/wbuser.pl
acl word_ban url_regex -i "/etc/squid/acl/word_ban.txt"
acl social_ban dstdomain "/etc/squid/acl/social_ban.txt"
acl anonim_ban dstdomain "/etc/squid/acl/anonimizers_ban.txt"
acl public_ban dstdomain "/etc/squid/acl/public_ban.txt"
acl multimedia_ban dstdomain "/etc/squid/acl/multimedia_ban.txt"
acl ban_for_all dstdomain "/etc/squid/acl/ban_for_all.txt"
acl webmail_ban dstdomain "/etc/squid/acl/webmail_ban.txt"
acl porno_ban dstdomain "/etc/squid/acl/porno_ban.txt"
acl tracker_ban dstdomain "/etc/squid/acl/tracker_ban.txt"
acl url_post_allow dstdomain "/etc/squid/acl/post.txt"
acl users_allow_all external perl_group squid_allow_all
acl users_only_post external perl_group squid_only_post
acl service external perl_group squid_service
acl vip_notban external perl_group squid_vip_notban
acl users_notban_mail external perl_group squid_notban_mail
acl vip_notban_mail external perl_group squid_vip_notban_mail
acl users_notban_mail-social external perl_group squid_notban_mail-social
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow users_only_post url_post_allow
http_access allow users_allow_all
http_access allow service !social_ban !webmail_ban !anonim_ban !public_ban
word_ban !multimedia_ban !tracker_ban !webmail_ban
http_access allow vip_notban !social_ban !anonim_ban !ban_for_all
http_access allow users_notban_mail !word_ban !social_ban !anonim_ban
ban_for_all !porno_ban !multimedia_ban !tracker_ban
http_access allow vip_notban_mail !word_ban !anonim_ban !ban_for_all
porno_ban
http_access allow users_notban_mail-social !word_ban !anonim_ban
!ban_for_all !porno_ban !multimedia_ban !tracker_ban
http_access allow localhost
http_access deny all
http_port 3128
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
refresh_pattern . 0 20% 4320
acl 80-80Mbit external perl_group squid_80-80Mbit
acl 80-20Mbit external perl_group squid_80-20Mbit
acl 50-5Mbit external perl_group squid_50-5Mbit
acl 10-2Mbit external perl_group squid_10-2Mbit
acl 10-1Mbit external perl_group squid_10-1Mbit
delay_class 1 2
delay_access 1 allow 80-80Mbit
delay_access 1 deny all
delay_parameters 1 10000000/10000000 10000000/3000000
delay_class 2 2
delay_access 2 allow 80-20Mbit
delay_access 2 deny all
delay_parameters 2 8000000/8000000 1250000/2048000
delay_class 3 2
delay_access 3 allow 50-5Mbit
delay_access 3 deny all
delay_parameters 3 6250000/10000000 625000/512000
delay_class 4 2
delay_access 4 allow 10-2Mbit
delay_access 4 deny all
delay_parameters 4 1250000/2000000 250000/256000
delay_class 5 2
delay_access 5 allow 10-1Mbit
delay_access 5 deny all
delay_parameters 5 1250000/2000000 125000/125000
cache_mem 128 MB
maximum_object_size_in_memory 64 KB
cache_dir ufs /var/spool/squid 2048 16 256
maximum_object_size 20480 KB
access_log /var/log/squid/access.log squid
cache_peer 127.0.0.1 parent 8080 0 no-query no-digest no-netdb-exchange default
cache_peer_access 127.0.0.1 allow all