Disallow usernames that contain certain words and RegExp (#2200)

* Add `disallowedwords` setting and perform check

Check if any of the words in `disallowedwords` are contained in the username. If
so, return false like other checks.

NOTE: Needs testing for advanced bugs.

* Remove "administrator" from `disallowedwords`

"administrator" contains "admin" anyway, so it is not needed.

* Add error message if username contains a disallowed word

* Add `disallowedregexp` setting and perform check

Check if each expression in `disallowedregexp` exactly matches the username. If
so, return false.

TODO: Add specific error to dialog in `window_main.cpp`.

* Add error message for username matching RegExp

* Fix indentation

* Compile `disallowedregexp` into a QList upon initialization

Reduces system load with each registration request.

* Clean up `isUsernameValid` function

* Fix indentation

* Add backwards compatibility to client

Client can accept either 7 or 9 rules to maintain compatibility with older
versions of server.

* Add examples and warnings to `servatrice.ini`
This commit is contained in:
Kevin Boxhoorn
2016-10-17 21:24:42 +11:00
committed by ctrlaltca
parent f20e2ce2bd
commit 0b7f4c134c
5 changed files with 49 additions and 7 deletions

View File

@@ -107,6 +107,18 @@ allowedpunctuation=_.-
; If a username can begin with punctuation defined in allowedpunctuation
allowpunctuationprefix=false
; Disallow usernames containing these words. This list is comma seperated, e.g.
; "admin,user,name"
disallowedwords="admin"
; Disallow usernames matching these regular expressions. This list is comma
; separated, e.g. "\\w+\\d+,\\d{2}user", hence you cannot use commas in your
; expressions. Backslashes must be escaped, so `\w+\d+` becomes `\\w+\\d+`.
; WARNING: Complex expressions can be harmful to performance. Please make sure
; your expressions are considered well formed. See this page for info:
; http://www.regular-expressions.info/catastrophic.html
disallowedregexp=""
[registration]
; Servatrice can process registration requests to add new users on the fly.