From 1492e02cb4f48de3ff33ed4d4db013aac00087d3 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 5 Jun 2012 19:37:45 +0000 Subject: [PATCH] Import OpenVPN cisco style radius attributes applying policy to logged in users. Feature #2100 --- etc/inc/auth.inc | 8 +++++--- etc/inc/filter.inc | 2 ++ etc/inc/openvpn.auth-user.php | 38 ++++++++++++++++++++++++++++++++++- etc/inc/openvpn.inc | 4 ++++ 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index 1c176abef7..614c93dc32 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -1127,7 +1127,7 @@ function ldap_backed($username, $passwd, $authcfg) { return true; } -function radius_backed($username, $passwd, $authcfg){ +function radius_backed($username, $passwd, $authcfg, &$attributes = array()) { global $debug, $config; $ret = false; @@ -1163,6 +1163,8 @@ function radius_backed($username, $passwd, $authcfg){ if ($debug) printf(gettext("Radius send failed: %s
\n"), $retvalue['error']); } else if ($result === true) { + if ($rauth->getAttributes()) + $attributes = $rauth->listAttributes(); $retvalue['auth_val'] = 2; if ($debug) printf(gettext("Radius Auth succeeded")."
\n"); @@ -1259,7 +1261,7 @@ function getUserGroups($username, $authcfg) { return $member_groups; } -function authenticate_user($username, $password, $authcfg = NULL) { +function authenticate_user($username, $password, $authcfg = NULL, &$attributes = array()) { if (!$authcfg) { return local_backed($username, $password); @@ -1272,7 +1274,7 @@ function authenticate_user($username, $password, $authcfg = NULL) { $authenticated = true; break; case 'radius': - if (radius_backed($username, $password, $authcfg)) + if (radius_backed($username, $password, $authcfg, $attributes)) $authenticated = true; break; default: diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index c417db11a0..16fbaf5b20 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -2365,6 +2365,8 @@ function filter_rules_generate() { /* relayd */ $ipfrules .= "anchor \"relayd/*\"\n"; + /* OpenVPN user rules from radius */ + $ipfrules .= "anchor \"openvpn/*\"\n"; # BEGIN OF firewall rules /* default block logging? */ if(!isset($config['syslog']['nologdefaultblock'])) diff --git a/etc/inc/openvpn.auth-user.php b/etc/inc/openvpn.auth-user.php index 0558dbb48b..92c3b876b8 100755 --- a/etc/inc/openvpn.auth-user.php +++ b/etc/inc/openvpn.auth-user.php @@ -96,6 +96,11 @@ if (!$username || !$password) { /* Replaced by a sed with propper variables used below(ldap parameters). */ //