-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Require AppserviceRegistrationType #9548
Changes from 7 commits
d4ce14e
9415c6e
775f282
6d28ee8
dba6ff4
8bd7eb6
2b86a5f
ca4213a
b3cf0fa
9502517
4d6f844
73c2d60
87720de
9b96033
c98ede5
3d080e6
e2637e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/register now requires a `body.type` value of `m.login.appservice` when registering appservice users. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import hmac | ||
import logging | ||
import random | ||
|
@@ -22,7 +21,7 @@ | |
import synapse | ||
import synapse.api.auth | ||
import synapse.types | ||
from synapse.api.constants import LoginType | ||
from synapse.api.constants import AppserviceRegistrationType, LoginType | ||
from synapse.api.errors import ( | ||
Codes, | ||
InteractiveAuthIncompleteError, | ||
|
@@ -428,15 +427,20 @@ async def on_POST(self, request): | |
raise SynapseError(400, "Invalid username") | ||
desired_username = body["username"] | ||
|
||
appservice = None | ||
if self.auth.has_access_token(request): | ||
appservice = self.auth.get_appservice_by_req(request) | ||
|
||
# fork off as soon as possible for ASes which have completely | ||
# different registration flows to normal users | ||
|
||
# == Application Service Registration == | ||
if appservice: | ||
if body.get("type") == AppserviceRegistrationType: | ||
if not self.auth.has_access_token(request): | ||
Half-Shot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
raise SynapseError( | ||
400, | ||
"Appservice token must be provided when using a type of m.login.application_service", | ||
) | ||
|
||
# Verify the AS | ||
self.auth.get_appservice_by_req(request) | ||
|
||
# Set the desired user according to the AS API (which uses the | ||
# 'user' key not 'username'). Since this is a new addition, we'll | ||
# fallback to 'username' if they gave one. | ||
|
@@ -457,6 +461,11 @@ async def on_POST(self, request): | |
) | ||
|
||
return 200, result | ||
elif self.auth.has_access_token(request): | ||
raise SynapseError( | ||
400, | ||
"A type of m.login.application_service must be provided when registering as an appservice", | ||
Half-Shot marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. passing an access token does not necessarily mean that you are claiming to be an appservice? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there is a case currently where you can register with an access token without being an appservice? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason for keeping this If we throw this statement away, the token will be ignored and requests that previously successfully created an appservice user may either fail with a somewhat unhelpful error (like "you didn't specify a password"), or may succeed in creating a non-appservice user which would probably do more harm than good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the point is more that the error message is ... unclear. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggested a rephrasing. |
||
|
||
# == Normal User Registration == (everyone else) | ||
if not self._registration_enabled: | ||
|
Uh oh!
There was an error while loading. Please reload this page.