-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
Can one of the admins verify this patch? |
2 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
@matrixbot ok to test |
There's a bunch of PEP8 violations:
You should be able to test locally by installing flake8 and then running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broadly looks good. If you can just add some docstring to:
- the functions in the handler and storage
- the classes in the rest layer explaining what they do
raise SynapseError(400, "Missing 'limit' arg") | ||
if not start: | ||
raise SynapseError(400, "Missing 'start' arg") | ||
logger.info("limit: %s, start: %s", limit, start) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be debug level logging.
raise SynapseError(400, "Missing 'limit' arg") | ||
if not start: | ||
raise SynapseError(400, "Missing 'start' arg") | ||
logger.info("limit: %s, start: %s", limit, start) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be debug level logging.
if not term: | ||
raise SynapseError(400, "Missing 'term' arg") | ||
|
||
logger.info("term: %s ", term) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be debug level logging.
synapse/storage/__init__.py
Outdated
@@ -284,6 +284,48 @@ def get_user_ip_and_agents(self, user): | |||
desc="get_user_ip_and_agents", | |||
) | |||
|
|||
def get_users(self, user): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this take a user
param?
synapse/handlers/admin.py
Outdated
def get_users_paginate(self, user, start, limit): | ||
ret = yield self.store.get_users_paginate(user, start, limit) | ||
|
||
defer.returnValue(ret) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions can simply be rewritten as:
def get_users_paginate(self, user, start, limit):
return self.store.get_users_paginate(user, start, limit)
scripts-dev/add_admin.py
Outdated
url = 'http://localhost:8008/_matrix/client/api/v1/register' | ||
post_data = {'user': 'admin', | ||
'password': 'admin123', | ||
'type': 'm.login.password'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit hesitant to add example scripts like this, as they can't directly be run. I believe the register_new_user
script actually has an option to specify the new user is an admin or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Made a new commit.
1- Fix all error from flake8
2- add docstring to all the new methods
3 - Used _simple_select_list_paginate as private method which is more generic to use for other list search as well and used get_user_list_paginate for calling from rest api
(The sytest dendron failure is probably spurious, ignore it) |
Hi,
Made a new commit.
1- Fix all error from flake8
2- add docstring to all the new methods
3 - Used _simple_select_list_paginate as private method which is more
generic to use for other list search as well and
used get_user_list_paginate for calling from rest api
…On Thu, Jan 19, 2017 at 2:32 PM, Erik Johnston ***@***.***> wrote:
(The sytest dendron failure is probably spurious, ignore it)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1784 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANONn-rSvU8bqpnebpQm95arJqxux77Vks5rT2XzgaJpZM4LeTG4>
.
|
01bbbcd
to
8f98f3f
Compare
a5b95b8
to
5ebeda6
Compare
5ebeda6
to
8324176
Compare
administrators can now: - Set displayname of users - Update user avatars - Search for users by user_id - Browse all users in a paginated API - Reset user passwords - Deactivate users Helpers for doing paginated queries has also been added to storage Signed-off-by: Morteza Araby <morteza.araby@ericsson.com>
8324176
to
2849d3f
Compare
Changes in synapse v0.19.3-rc1 (2017-03-08) =========================================== Features: * Add some administration functionalities. Thanks to morteza-araby! (PR #1784) Changes: * Reduce database table sizes (PR #1873, #1916, #1923, #1963) * Update contrib/ to not use syutil. Thanks to andrewshadura! (PR #1907) * Don't fetch current state when sending an event in common case (PR #1955) Bug fixes: * Fix synapse_port_db failure. Thanks to Pneumaticat! (PR #1904) * Fix caching to not cache error responses (PR #1913) * Fix APIs to make kick & ban reasons work (PR #1917) * Fix bugs in the /keys/changes api (PR #1921) * Fix bug where users couldn't forget rooms they were banned from (PR #1922) * Fix issue with long language values in pushers API (PR #1925) * Fix a race in transaction queue (PR #1930) * Fix dynamic thumbnailing to preserve aspect ratio. Thanks to jkolo! (PR #1945) * Fix device list update to not constantly resync (PR #1964) * Fix potential for huge memory usage when getting device that have changed (PR #1969)
It'd be nice if someone could write something in https://github.com/matrix-org/synapse/tree/master/docs/admin_api about this. |
Also, it would be great if the swagger ui supported this. |
The swagger spec is limited to the client-server API. These APIs are synapse-specific. Of course, you could give them a swagger UI, but it wouldn't be appropriate to include them in the current one. |
It would probably be more appropriate to write a little synapse admin client instead |
@@ -25,6 +26,34 @@ | |||
logger = logging.getLogger(__name__) | |||
|
|||
|
|||
class UsersRestServlet(ClientV1RestServlet): | |||
PATTERNS = client_path_patterns("/admin/users/(?P<user_id>[^/]*)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is my understanding correct? this takes a user_id, and then ignores it? @morteza-araby
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, I must have missed that. The UsersRest Api, has not been used at my client side implementation and I think that's why I've missed all of your comments here. Probably should have wrote some test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now tracked as #2522
# raise AuthError(403, "You are not a server admin") | ||
|
||
if not self.hs.is_mine(target_user): | ||
raise SynapseError(400, "Can only users a local user") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this error makes no sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right.
if not new_password: | ||
raise SynapseError(400, "Missing 'new_password' arg") | ||
|
||
logger.info("new_password: %r", new_password) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we really shouldn't log passwords at info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it should...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this finally got fixed by #4965
I haven't (yet) documented all of the user-list APIs introduced in #1784 because the API shape seems very odd, given the functionality.
I haven't (yet) documented all of the user-list APIs introduced in #1784 because the API shape seems very odd, given the functionality.
1- Get Request to get list of users for administrator
2- Post request to reset password for users
3 - Get Request to get a paginated users With start and limit.
4 - Search users from database and return an array of found users or empty