[pve-devel] [PATCH access-control] Auth::LDAP, Auth::AD: ipv6 support

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Dec 2 16:06:46 CET 2015


Also had to change server1/server2 schema from a pattern to
the 'address' format.
---
 PVE/Auth/AD.pm   | 6 ++++--
 PVE/Auth/LDAP.pm | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/PVE/Auth/AD.pm b/PVE/Auth/AD.pm
index d33d393..e03d04c 100755
--- a/PVE/Auth/AD.pm
+++ b/PVE/Auth/AD.pm
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use PVE::Auth::Plugin;
 use Net::LDAP;
+use Net::IP;
 
 use base qw(PVE::Auth::Plugin);
 
@@ -16,14 +17,14 @@ sub properties {
 	server1 => { 
 	    description => "Server IP address (or DNS name)",		
 	    type => 'string',
-	    pattern => '[\w\d]+(.[\w\d]+)*',
+	    format => 'address',
 	    maxLength => 256,
 	},
 	server2 => { 
 	    description => "Fallback Server IP address (or DNS name)",
 	    type => 'string',
 	    optional => 1,
-	    pattern => '[\w\d]+(.[\w\d]+)*',
+	    format => 'address',
 	    maxLength => 256,
 	},
 	secure => { 
@@ -80,6 +81,7 @@ my $authenticate_user_ad = sub {
     my $default_port = $config->{secure} ? 636: 389;
     my $port = $config->{port} ? $config->{port} : $default_port;
     my $scheme = $config->{secure} ? 'ldaps' : 'ldap';
+    $server = "[$server]" if Net::IP::ip_is_ipv6($server);
     my $conn_string = "$scheme://${server}:$port";
     
     my $ldap = Net::LDAP->new($conn_string) || die "$@\n";
diff --git a/PVE/Auth/LDAP.pm b/PVE/Auth/LDAP.pm
index 3f867ec..e1161b6 100755
--- a/PVE/Auth/LDAP.pm
+++ b/PVE/Auth/LDAP.pm
@@ -5,6 +5,7 @@ use warnings;
 
 use PVE::Auth::Plugin;
 use Net::LDAP;
+use Net::IP;
 use base qw(PVE::Auth::Plugin);
 
 sub type {
@@ -50,6 +51,7 @@ my $authenticate_user_ldap = sub {
     my $default_port = $config->{secure} ? 636: 389;
     my $port = $config->{port} ? $config->{port} : $default_port;
     my $scheme = $config->{secure} ? 'ldaps' : 'ldap';
+    $server = "[$server]" if Net::IP::ip_is_ipv6($server);
     my $conn_string = "$scheme://${server}:$port";
 
     my $ldap = Net::LDAP->new($conn_string, verify => 'none') || die "$@\n";
-- 
2.1.4





More information about the pve-devel mailing list