aboutsummaryrefslogtreecommitdiff
path: root/clientapi
diff options
context:
space:
mode:
authorS7evinK <2353100+S7evinK@users.noreply.github.com>2022-03-07 18:14:08 +0100
committerGitHub <noreply@github.com>2022-03-07 18:14:08 +0100
commit05fa66c9c87c1ad32ab3d1554f53475ed1f40707 (patch)
tree1e73cda4f8c8b0b0d72e23b5223dc3cb84b02793 /clientapi
parent626d3f6cf5b743d843d73cc79ce06bdef09dd38e (diff)
Fix appservice username check (#2223)
* Fix appservice username check * Flakey test moved to blocklist * Move tests to blacklist
Diffstat (limited to 'clientapi')
-rw-r--r--clientapi/routing/directory.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/clientapi/routing/directory.go b/clientapi/routing/directory.go
index e408c264..ac355b5d 100644
--- a/clientapi/routing/directory.go
+++ b/clientapi/routing/directory.go
@@ -139,11 +139,17 @@ func SetLocalAlias(
// TODO: This code should eventually be refactored with:
// 1. The new method for checking for things matching an AS's namespace
// 2. Using an overall Regex object for all AS's just like we did for usernames
-
+ reqUserID, _, err := gomatrixserverlib.SplitID('@', device.UserID)
+ if err != nil {
+ return util.JSONResponse{
+ Code: http.StatusBadRequest,
+ JSON: jsonerror.BadJSON("User ID must be in the form '@localpart:domain'"),
+ }
+ }
for _, appservice := range cfg.Derived.ApplicationServices {
// Don't prevent AS from creating aliases in its own namespace
// Note that Dendrite uses SenderLocalpart as UserID for AS users
- if device.UserID != appservice.SenderLocalpart {
+ if reqUserID != appservice.SenderLocalpart {
if aliasNamespaces, ok := appservice.NamespaceMap["aliases"]; ok {
for _, namespace := range aliasNamespaces {
if namespace.Exclusive && namespace.RegexpObject.MatchString(alias) {