fix: a service account may be named by a GUID in lowercase, as the Router Manager proposes for a new one.
Release / release (push) Successful in 14s
Release / release (push) Successful in 14s
This commit is contained in:
1 parent
e675540ce2
commit
d1d565b1d9
3 files changed
+22
-6
No files matched your search
@@ -74,6 +74,8 @@ import vpnrouter_pki
|
||||
|
||||
#: A user name is one lowercase DNS label, as it is also the common name of the certificate.
|
||||
NAME = re.compile(r'^[a-z][a-z0-9-]{0,30}[a-z0-9]$|^[a-z]$')
|
||||
#: The other name of a service account: a GUID in lowercase hexadecimal, as the Router Manager proposes one.
|
||||
GUID = re.compile(r'^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$')
|
||||
PASSWORD_MIN = 8
|
||||
PASSWORD_MAX = 128
|
||||
#: The longest first or last name, in characters.
|
||||
@@ -135,9 +137,11 @@ def session():
|
||||
connection.unbind_s()
|
||||
|
||||
|
||||
def check_name(name):
|
||||
if not isinstance(name, str) or not NAME.match(name):
|
||||
raise Failure('a user name is 1 to 32 lowercase letters, digits and hyphens, starting with a letter', 2)
|
||||
def check_name(name, service=True):
|
||||
"""Refuse a name that is not a user name (NAME), or, with service, the GUID of a service account either."""
|
||||
if not isinstance(name, str) or not (NAME.match(name) or service and GUID.match(name)):
|
||||
raise Failure('a user name is 1 to 32 lowercase letters, digits and hyphens, starting with a letter'
|
||||
+ (', or, for a service account, a GUID in lowercase' if service else ''), 2)
|
||||
|
||||
|
||||
def check_password(value):
|
||||
@@ -462,8 +466,8 @@ def list_users(connection):
|
||||
def add(connection, name, password, values, service=False):
|
||||
"""Add a user: a VPN user with its certificate when values gives all three person attributes, a Manager-only account
|
||||
with at most the e-mail address when it gives neither name, and, with service, a service account, with at most the
|
||||
e-mail address and its labels (labels)."""
|
||||
check_name(name)
|
||||
e-mail address and its labels (labels); only a service account may be named by a GUID."""
|
||||
check_name(name, service)
|
||||
details = person(values, required=False)
|
||||
vpn_user = 'givenName' in details or 'sn' in details
|
||||
if service and vpn_user:
|
||||
|
||||
Reference in new issue
Block a user