Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Prevent AS user check if no AS registered (#392)
Browse files Browse the repository at this point in the history
When a user registered on a homeserver with no application services
 registered, registration would check if the meta-regexp object matched
 the proposed user's new username.

 Apparently "" is a regex that matches everything, so every user was
 then barred from registering as they were supposedly registering inside
 an AS' exclusive namespace.

 This change prevents that check from happening by setting the exclusive
 regex to ^$ instead, preventing any matches from occurring.

 We also prevent the check for exclusivity if there are no namespaces
 registered for performance.

Signed-off-by: Andrew Morgan (https://amorgan.xyz) <[email protected]>
  • Loading branch information
anoadragon453 authored and erikjohnston committed Feb 27, 2018
1 parent 08274ba commit dfcf31f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, "|")
Expand Down

0 comments on commit dfcf31f

Please sign in to comment.