Allow longer & shorter usernames, complying with the MXID length spec

This commit is contained in:
Quentin Gliech
2024-12-19 12:12:34 +01:00
parent 961dd68005
commit 1e3d838c99
9 changed files with 89 additions and 26 deletions

View File

@@ -13,14 +13,17 @@ allow if {
count(violation) == 0
}
mxid(username, server_name) := sprintf("@%s:%s", [username, server_name])
# METADATA
# entrypoint: true
violation contains {"field": "username", "msg": "username too short"} if {
count(input.username) <= 2
count(input.username) == 0
}
violation contains {"field": "username", "msg": "username too long"} if {
count(input.username) > 64
user_id := mxid(input.username, data.server_name)
count(user_id) > 255
}
violation contains {"field": "username", "msg": "username contains invalid characters"} if {