add name sanitization

This commit is contained in:
Leticia Portella 2018-10-12 11:25:01 -03:00
parent f68deb3168
commit 1816ba38bb
2 changed files with 11 additions and 0 deletions

View file

@ -52,6 +52,11 @@ login by attacking via ssh or another mean.
To change your password, you should login in your jupyterhub account,
go to `<your_server_ip>/hub/auth/change-password` and change the password.
#### I'm getting an error when creating my username
Usernames cannot contain spaces or commas. Please check if your username is free
of these characters.
## Security
When using `FirstUseAuthenticator` it is advised to automatically prepend the

View file

@ -93,6 +93,12 @@ class FirstUseAuthenticator(Authenticator):
"""
return self.db.query(User).filter_by(name=username).first() is not None
def validate_username(self, name):
invalid_chars = [',', ' ']
if any((char in name) for char in invalid_chars):
return False
return super().validate_username()
@gen.coroutine
def authenticate(self, handler, data):
username = data['username']