Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin usernames can not include dots #11

Closed
alfem opened this issue Jun 1, 2015 · 3 comments
Closed

Admin usernames can not include dots #11

alfem opened this issue Jun 1, 2015 · 3 comments
Milestone

Comments

@alfem
Copy link
Member

alfem commented Jun 1, 2015

In corporative world usernames with dots (separating first name and last name, for example) are very common.

Control Center admin users can not include a dot, possibly due to a Chef constraint.

However, workstation users in the organizational tree can include dots, as they are translated back and forth to "###" when needed.

Suggestion: A sanitize username function could be useful for both kind of users.

@alfem alfem added this to the 2.1.10 milestone Jun 1, 2015
@System25
Copy link
Contributor

System25 commented Jun 2, 2015

Hi Alfonso,
Control Center admin users are limited to lower case letters and numbers:
https://github.com/gecos-team/gecoscc-ui/blob/master/gecoscc/models.py

class LowerAlphaNumeric(object):
err_msg = _('Only lowercase letters or numbers')
regex = re.compile(r'^([a-z]|[0-9])*$')
def call(self, node, value):
if not self.regex.match(value):
node.raise_invalid(self.err_msg)

Chef usernames are sanitized by replacing the dots by underscores:
https://github.com/chef/chef-server-webui/blob/master/app/models/user.rb

def name=(n)
@name = n.gsub(/./, '_')
end

Also Chef saves the user via the REST API so the username must create a proper URI, so it must be limited to [ ALPHA / DIGIT / "-" / "_" / "~" ]

Maybe the sanitize function must force the username to match the following regular expression: [A-Za-z0-9-_~]

Do you think that "admin usernames " and "workstation usernames" must be sanitized by using this regular expression?

@alfem
Copy link
Member Author

alfem commented Jun 2, 2015

Yes, it looks a pretty straight forward solution, although I think that regexp must be implemented in our Control Center before saving/retrieving admin useres to/from Chef.

System25 added a commit to System25/gecoscc-ui that referenced this issue Jun 2, 2015
…wercase letters, numbers, hyphen and underscore
@System25
Copy link
Contributor

System25 commented Jun 2, 2015

Testing with different usernames in the Chef Server administration area I noticed that the usernames must be in lower case and the "~" characters also is forbidden.
To the final regular expression to match is [a-z0-9-_]

System25 added a commit to System25/gecoscc-ui that referenced this issue Jun 3, 2015
…dmits lowercase letters, numbers, hyphen and underscore"

This reverts commit ccaa6d5.
System25 added a commit to System25/gecoscc-ui that referenced this issue Jun 3, 2015
System25 added a commit to System25/gecoscc-ui that referenced this issue Jun 5, 2015
@alfem alfem closed this as completed Jul 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants