From a3c50828a631d7627f0db34548773c594430220e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20BECOT?= Date: Fri, 19 Nov 2021 00:34:16 +0100 Subject: [PATCH] feat: Allow underscores and hyphens in account name --- powerdnsadmin/models/account.py | 2 +- powerdnsadmin/routes/index.py | 10 +++++----- powerdnsadmin/templates/admin_edit_account.html | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/powerdnsadmin/models/account.py b/powerdnsadmin/models/account.py index 4d08fc1..4e3ca97 100644 --- a/powerdnsadmin/models/account.py +++ b/powerdnsadmin/models/account.py @@ -35,7 +35,7 @@ class Account(db.Model): if self.name is not None: self.name = ''.join(c for c in self.name.lower() - if c in "abcdefghijklmnopqrstuvwxyz0123456789") + if c in "abcdefghijklmnopqrstuvwxyz0123456789_-") def __repr__(self): return ''.format(self.name) diff --git a/powerdnsadmin/routes/index.py b/powerdnsadmin/routes/index.py index d2a7e0a..342b06e 100644 --- a/powerdnsadmin/routes/index.py +++ b/powerdnsadmin/routes/index.py @@ -331,7 +331,7 @@ def login(): # check if user has permissions account_users = account.get_user() current_app.logger.info('Group: {} Users: {}'.format( - group_name, + group_name, account_users)) if user.id in account_users: current_app.logger.info('User id {} is already in account {}'.format( @@ -351,7 +351,7 @@ def login(): account.mail = '' account.create_account() history = History(msg='Create account {0}'.format( - account.name), + account.name), created_by='System') history.add() @@ -485,13 +485,13 @@ def login(): saml_enabled=SAML_ENABLED, error='Token required') - if Setting().get('autoprovisioning') and auth_method!='LOCAL': + if Setting().get('autoprovisioning') and auth_method!='LOCAL': urn_value=Setting().get('urn_value') Entitlements=user.read_entitlements(Setting().get('autoprovisioning_attribute')) if len(Entitlements)==0 and Setting().get('purge'): user.set_role("User") user.revoke_privilege(True) - + elif len(Entitlements)!=0: if checkForPDAEntries(Entitlements, urn_value): user.updateUser(Entitlements) @@ -1093,7 +1093,7 @@ def create_group_to_account_mapping(): def handle_account(account_name, account_description=""): clean_name = ''.join(c for c in account_name.lower() - if c in "abcdefghijklmnopqrstuvwxyz0123456789") + if c in "abcdefghijklmnopqrstuvwxyz0123456789_-") if len(clean_name) > Account.name.type.length: current_app.logger.error( "Account name {0} too long. Truncated.".format(clean_name)) diff --git a/powerdnsadmin/templates/admin_edit_account.html b/powerdnsadmin/templates/admin_edit_account.html index 41f2d43..0514ead 100644 --- a/powerdnsadmin/templates/admin_edit_account.html +++ b/powerdnsadmin/templates/admin_edit_account.html @@ -49,7 +49,7 @@ {% if invalid_accountname %} Cannot be blank and must only contain alphanumeric - characters. + characters, hyphens or underscores. {% elif duplicate_accountname %} Account name already in use. {% endif %} @@ -112,8 +112,8 @@

Fill in all the fields to the in the form to the left.

- Name is an account identifier. It will be stored as all lowercase letters (no - spaces, special characters etc).
+ Name is an account identifier. It will be lowercased and can contain alphanumeric + characters, hyphens and underscores (no space or other special character is allowed).
Description is a user friendly name for this account.
Contact person is the name of a contact person at the account.
Mail Address is an e-mail address for the contact person.