Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Administration functionalities #1784
Conversation
matrixbot
commented
Jan 9, 2017
|
Can one of the admins verify this patch? |
matrixbot
commented
Jan 9, 2017
|
Can one of the admins verify this patch? |
matrixbot
commented
Jan 9, 2017
|
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 |
erikjohnston
reviewed
Jan 19, 2017
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
| + url = 'http://localhost:8008/_matrix/client/api/v1/register' | ||
| + post_data = {'user': 'admin', | ||
| + 'password': 'admin123', | ||
| + 'type': 'm.login.password'} |
erikjohnston
Jan 19, 2017
Owner
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.
morteza-araby
Jan 21, 2017
Contributor
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
| + def get_users_paginate(self, user, start, limit): | ||
| + ret = yield self.store.get_users_paginate(user, start, limit) | ||
| + | ||
| + defer.returnValue(ret) |
erikjohnston
Jan 19, 2017
Owner
These functions can simply be rewritten as:
def get_users_paginate(self, user, start, limit):
return self.store.get_users_paginate(user, start, limit)| + raise SynapseError(400, "Missing 'limit' arg") | ||
| + if not start: | ||
| + raise SynapseError(400, "Missing 'start' arg") | ||
| + logger.info("limit: %s, start: %s", limit, start) |
| + raise SynapseError(400, "Missing 'limit' arg") | ||
| + if not start: | ||
| + raise SynapseError(400, "Missing 'start' arg") | ||
| + logger.info("limit: %s, start: %s", limit, start) |
| + if not term: | ||
| + raise SynapseError(400, "Missing 'term' arg") | ||
| + | ||
| + logger.info("term: %s ", term) |
| @@ -284,6 +284,48 @@ def get_user_ip_and_agents(self, user): | ||
| desc="get_user_ip_and_agents", | ||
| ) | ||
| + def get_users(self, user): |
|
(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
…
|
morteza-araby
changed the base branch from
master
to
develop
Feb 2, 2017
erikjohnston
merged commit af6da6d
into
matrix-org:develop
Feb 6, 2017
erikjohnston
added a commit
that referenced
this pull request
Mar 13, 2017
|
It'd be nice if someone could write something in https://github.com/matrix-org/synapse/tree/master/docs/admin_api about this. |
jcgruenhage
commented
Mar 22, 2017
|
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. |
jcgruenhage
commented
Mar 22, 2017
|
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>[^/]*)") |
richvdh
Apr 20, 2017
Member
is my understanding correct? this takes a user_id, and then ignores it? @morteza-araby
morteza-araby
Apr 21, 2017
Contributor
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.
| + # 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") |
| + if not new_password: | ||
| + raise SynapseError(400, "Missing 'new_password' arg") | ||
| + | ||
| + logger.info("new_password: %r", new_password) |
morteza-araby commentedJan 9, 2017
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