diff --git a/src/github.com/matrix-org/dendrite/clientapi/routing/register.go b/src/github.com/matrix-org/dendrite/clientapi/routing/register.go index 107344c3..77e875ec 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/register.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/register.go @@ -381,8 +381,9 @@ func Register( } // Make sure normal user isn't registering under an exclusive application - // service namespace + // service namespace. Skip this check if no app services are registered. if r.Auth.Type != "m.login.application_service" && + len(cfg.Derived.ApplicationServices) != 0 && cfg.Derived.ExclusiveApplicationServicesUsernameRegexp.MatchString(r.Username) { return util.JSONResponse{ Code: 400, diff --git a/src/github.com/matrix-org/dendrite/common/config/appservice.go b/src/github.com/matrix-org/dendrite/common/config/appservice.go index 72efafac..b57e9d06 100644 --- a/src/github.com/matrix-org/dendrite/common/config/appservice.go +++ b/src/github.com/matrix-org/dendrite/common/config/appservice.go @@ -113,6 +113,12 @@ func setupRegexps(cfg *Dendrite) { // regex and deny access if it isn't from an application service exclusiveUsernames := strings.Join(exclusiveUsernameStrings, "|") + // If there are no exclusive username regexes, compile string so that it + // will not match any valid usernames + if exclusiveUsernames == "" { + exclusiveUsernames = "^$" + } + // TODO: Aliases and rooms. Needed? //exclusiveAliases := strings.Join(exclusiveAliasStrings, "|") //exclusiveRooms := strings.Join(exclusiveRoomStrings, "|")