mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-26 13:41:33 +00:00
Prevent AS user check if no AS registered (#392)
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) <andrew@amorgan.xyz>
This commit is contained in:
parent
08274bab5a
commit
dfcf31f293
@ -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,
|
||||
|
@ -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, "|")
|
||||
|
Loading…
Reference in New Issue
Block a user