-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
23 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
import re | ||
import socket | ||
import ldap | ||
import six | ||
import netaddr | ||
from .iamvpnbase import IAMVPNLibraryBase, ParsedACL | ||
|
||
|
@@ -140,7 +139,7 @@ def _get_user_dn_by_username(self, input_username): | |
return: str of their DN | ||
raises if there's no such user. | ||
""" | ||
if not isinstance(input_username, six.string_types): | ||
if not isinstance(input_username, str): | ||
raise TypeError(input_username, 'Argument must be a string') | ||
res = self.conn.search_s( | ||
self.config.get('ldap_base'), ldap.SCOPE_SUBTREE, | ||
|
@@ -269,7 +268,7 @@ def _split_vpn_acl_string(input_string): # pylint: disable=too-many-branches | |
return: ParsedACL | ||
raise for horrible inputs | ||
""" | ||
if not isinstance(input_string, six.string_types): | ||
if not isinstance(input_string, str): | ||
raise TypeError(input_string, 'Argument must be a string') | ||
# input_string should be: | ||
# '1.1.1.1 # foo.m.c' | ||
|
@@ -361,7 +360,7 @@ def _fetch_vpn_acls_for_user(self, input_email): | |
input_email: "[email protected]" | ||
return: ldap response | ||
""" | ||
if not isinstance(input_email, six.string_types): | ||
if not isinstance(input_email, str): | ||
raise TypeError(input_email, 'Argument must be a string') | ||
user_dn = self._get_user_dn_by_username(input_email) | ||
rdn_attr = self.config.get('ldap_vpn_acls_rdn_attribute') | ||
|
@@ -401,7 +400,7 @@ def _sanitized_vpn_acls_for_user(self, input_email): # pylint: disable=too-many | |
different people want different results (every ACL? every IP? | ||
Just the IPs? What about a CIDR that encapsulates another?) | ||
""" | ||
if not isinstance(input_email, six.string_types): | ||
if not isinstance(input_email, str): | ||
raise TypeError(input_email, 'Argument must be a string') | ||
raw_acls = self._fetch_vpn_acls_for_user(input_email) | ||
acls = [] | ||
|
@@ -482,7 +481,7 @@ def user_allowed_to_vpn(self, input_email): | |
Outside user: duo_openvpn | ||
Outside user: duo_openvpn kill script | ||
""" | ||
if not isinstance(input_email, six.string_types): | ||
if not isinstance(input_email, str): | ||
raise TypeError(input_email, 'Argument must be a string') | ||
if not self.is_online(): | ||
return self.fail_open | ||
|
@@ -513,7 +512,7 @@ def does_user_require_vpn_mfa(self, input_email): | |
Outside user: duo_openvpn | ||
""" | ||
if not isinstance(input_email, six.string_types): | ||
if not isinstance(input_email, str): | ||
raise TypeError(input_email, 'Argument must be a string') | ||
if not self.is_online(): | ||
# This is going to be a bit of mental gymnastics. | ||
|
@@ -570,7 +569,7 @@ def get_allowed_vpn_ips(self, input_email): | |
Outside user: openvpn-client-connect | ||
""" | ||
if not isinstance(input_email, six.string_types): | ||
if not isinstance(input_email, str): | ||
raise TypeError(input_email, 'Argument must be a string') | ||
if not self.is_online(): | ||
# Absentee server means no IPs | ||
|
@@ -591,7 +590,7 @@ def get_allowed_vpn_acls(self, input_email): | |
Outside user: openvpn-netfilter | ||
""" | ||
if not isinstance(input_email, six.string_types): | ||
if not isinstance(input_email, str): | ||
raise TypeError(input_email, 'Argument must be a string') | ||
if not self.is_online(): | ||
# Absentee server means no ACLs | ||
|
@@ -614,9 +613,9 @@ def non_mfa_vpn_authentication(self, input_username, input_password): | |
Outside user: duo_openvpn | ||
""" | ||
if not isinstance(input_username, six.string_types): | ||
if not isinstance(input_username, str): | ||
raise TypeError(input_username, 'Argument must be a string') | ||
if not isinstance(input_password, six.string_types): | ||
if not isinstance(input_password, str): | ||
raise TypeError(input_password, 'Argument must be a string') | ||
if not self.is_online(): | ||
# A user could not be looked up. fail open as needed. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters