mirror of https://github.com/zulip/zulip.git
6dd6fc045f
The endpoint was lacking validation that the authentication_methods dict submitted by the user made sense. So e.g. it allowed submitting a nonsense key like NoSuchBackend or modifying the realm's configured authentication methods for a backend that's not enabled on the server, which should not be allowed. Both were ultimately harmless, because: 1. Submitting NoSuchBackend would luckily just trigger a KeyError inside the transaction.atomic() block in do_set_realm_authentication_methods so it would actually roll back the database changes it was trying to make. So this couldn't actually create some weird RealmAuthenticationMethod entries. 2. Silently enabling or disabling e.g. GitHub for a realm when GitHub isn't enabled on the server doesn't really change anything. And this action is only available to the realm's admins to begin with, so there's no attack vector here. test_supported_backends_only_updated wasn't actually testing anything, because the state it was asserting: ``` self.assertFalse(github_auth_enabled(realm)) self.assertTrue(dev_auth_enabled(realm)) self.assertFalse(password_auth_enabled(realm)) ``` matched the desired state submitted to the API... ``` result = self.client_patch( "/json/realm", { "authentication_methods": orjson.dumps( {"Email": False, "Dev": True, "GitHub": False} ).decode() }, ) ``` so we just replace it with a new test that tests the param validation. |
||
---|---|---|
.. | ||
actions | ||
data_import | ||
integration_fixtures/nagios | ||
lib | ||
management | ||
migrations | ||
models | ||
openapi | ||
tests | ||
tornado | ||
transaction_tests | ||
views | ||
webhooks | ||
worker | ||
__init__.py | ||
apps.py | ||
context_processors.py | ||
decorator.py | ||
filters.py | ||
forms.py | ||
logging_handlers.py | ||
middleware.py | ||
signals.py |