Commit Graph

114 Commits

Author SHA1 Message Date
Sean McGivern 6dc424c949 Merge branch '29903-remove-user-is-admin-flag-from-api' into 'master'
Don't display the `is_admin?` flag for user API responses

Closes #29903

See merge request !10846
2017-04-25 10:57:32 +00:00
Timothy Andrew 34b71e734b Don't display the `is_admin?` flag for user API responses.
- To prevent an attacker from enumerating the `/users` API to get a list of all
  the admins.

- Display the `is_admin?` flag wherever we display the `private_token` - at the
  moment, there are two instances:

  - When an admin uses `sudo` to view the `/user` endpoint
  - When logging in using the `/session` endpoint
2017-04-25 09:46:05 +00:00
Jacopo ff76adb547 Unnecessary "include WaitForAjax" and "include ApiHelpers"
Removed all the unnecessary include of `WaitForAjax` and `ApiHelpers` in the specs.
Removed unnecessary usage of `api:true`
2017-04-21 22:32:02 +02:00
Robert Speicher 93e23a5d71 Merge branch 'query-users-by-extern-uid' into 'master'
Implement search by extern_uid in Users API

See merge request !10509
2017-04-19 19:50:38 +00:00
Robin Bobbitt ddf7e6ae78 Implement search by extern_uid in Users API 2017-04-18 14:55:32 -04:00
Rémy Coutable 814212621f Expose `last_activity_on` in the User API
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-04-14 15:20:55 +02:00
Sean McGivern 91ac0e038a Port 'Add user activities API' to CE
CE port of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/962
2017-04-14 15:20:55 +02:00
Stan Hu 6a2d022d1d Delete users asynchronously 2017-04-02 05:37:05 -07:00
Douwe Maan 6a52cda31d Merge remote-tracking branch 'origin/personal_access_token_api_and_impersonation_token' 2017-03-07 09:29:55 -06:00
Tiago Botelho 005749a616 apply codestyle and implementation changes to the respective feature code 2017-03-06 19:18:26 +00:00
Adam Niedzielski 5753acfabc Move schema definitions for our public API to a separate directory 2017-03-06 14:17:07 +01:00
Tiago Botelho 2b474dc2b2 refactors finder and correlated code 2017-03-01 13:11:11 +00:00
Tiago Botelho 9f2e4742e3 applies relevant changes to the code and code structure 2017-02-28 22:15:40 +00:00
Tiago Botelho f0ea7130f7 refactors documentation and personal access tokens form to not allow admins to generate non impersionation tokens 2017-02-28 22:15:40 +00:00
Simon Vocella a3dfb58e7f add impersonation token 2017-02-28 22:15:39 +00:00
Simon Vocella 81246e5649 manage personal_access_tokens through api 2017-02-28 22:15:39 +00:00
Robert Schilling 86c58687b2 Return 204 for delete endpoints 2017-02-28 08:32:38 +01:00
Rémy Coutable 6f5bf9fcbb Merge branch 'remove-paginated-ressource' into 'master'
Remove shared example for pagination

See merge request !9377
2017-02-20 17:06:46 +00:00
Robert Schilling 993c3d14d5 Remove shared example for pagination 2017-02-20 15:39:16 +01:00
Robert Schilling 8f690604a5 API: Use POST to (un)block a user 2017-02-20 15:18:40 +01:00
Robert Schilling c70dfbc686 Add a custom pagination matcher 2017-02-16 15:38:40 +01:00
Robert Schilling 01ea65e0e9 Paginate all endpoints that return an array 2017-02-16 15:32:01 +01:00
Joost Rijneveld 6fab6d94ce
Optionally make users created via the API set their password 2017-02-09 20:32:54 +01:00
George Andrinopoulos d796e4fc37 Update api docs and minor changes 2017-02-02 17:15:02 +02:00
George Andrinopoulos 19dda1606b Force new password after password reset via API 2017-02-02 12:47:23 +02:00
Mark Fletcher 72c68b98ae Fix Users API to accept confirm parameter 2017-01-11 14:38:41 +00:00
Rémy Coutable 042bcdd555
Add a failing spec to the POST /users API
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-01-04 17:29:55 +01:00
Robert Schilling 15932c360c API: extern_uid is a string 2017-01-03 08:44:33 +01:00
Rémy Coutable 2f45d3bcf0 API: Memoize the current_user so that the sudo can work properly
The issue was arising when `#current_user` was called a second time
after a user was impersonated: the `User#is_admin?` check would be
performed on it and it would fail.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-12 13:50:31 +01:00
tiagonbotelho 3ed96afc47 adds impersonator variable and makes sudo usage overall more clear 2016-12-07 14:42:51 +00:00
Livier eb4f15571d Changed API spec files to describe the correct class
Restore changes for api spec files

Fix error in rspec Users

Delete extra space Repositories-spec
2016-11-28 10:55:27 -07:00
Robert Schilling 4cb3c0b404 Grapify the users API 2016-11-21 10:53:28 +01:00
Yatish Mehta a0aaf93fe5
Add query param to filter users on 'external' & 'blocked' type on API 2016-11-08 12:04:05 -08:00
Airat Shigapov 05084a4565
Make events order spec deterministic, create only 3 record instead of 5, explicitely check for events order 2016-10-24 22:56:28 +03:00
Airat Shigapov ae099857b0
Rewrite events order spec to simulate wrong order without changing ids 2016-10-24 22:56:28 +03:00
Airat Shigapov e15f15d5a8
Add test for events order in API 2016-10-24 22:56:27 +03:00
Airat Shigapov b939529c2a
Fix wrong endpoint in api/users documentation, fix same typo in spec describe blocks 2016-10-21 18:05:36 +03:00
Robert Speicher 7c07c07d7a Merge branch 'user-events-api' into 'master'
API: New /users/:id/events endpoint

## What does this MR do?

If add a new `/users/:id/events` endpoint to retrieve a user's contribution events. The events returned are filtered so that only the events for projects that the current user can see are returned (similarly to what we do at the controller level).

## Why was this MR needed?

Because it's a nice feature to calculate leaderboards, for instance for #17815.

## What are the relevant issue numbers?

Closes #20866.

See merge request !6771
2016-10-12 11:33:19 +00:00
Rémy Coutable c786578657
Make spec deterministic
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-10-11 21:26:49 +02:00
Rémy Coutable 8e70cf2564
Addresses Robert's feedback
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-10-11 17:25:57 +02:00
Dmitriy Zaporozhets 3e49123dd5 Fix api users spec for post request with invalid id
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-10-10 16:32:32 +03:00
Dmitriy Zaporozhets 137ebcfb3c Replace undefined Grape routing code from 400 to 404
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-10-10 16:32:32 +03:00
Dmitriy Zaporozhets fdfc93679d Fix API specs behaviour for invalid routing
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-10-10 16:32:32 +03:00
Dmitriy Zaporozhets d6cfc0042e Catch any undefined API routing and return 400 Bad Request
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-10-10 16:32:32 +03:00
Rémy Coutable 33ce197645
API: New /users/:id/events endpoint
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-10-10 13:35:53 +02:00
Dmitriy Zaporozhets 0614cf1954
Add extra check for api users spec
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-09-27 14:46:39 +03:00
Dmitriy Zaporozhets c17383a730 Improvements to user organization field feature after code review
* Add newline to user organization spec according to test guide
* Remove unnecessary comments from user organization database migration

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-09-27 14:04:39 +03:00
Dmitriy Zaporozhets d0b556eb1b Add User#organization to users api
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-09-27 14:04:39 +03:00
Timothy Andrew 727dff3f15 Don't expose a user's private token in the `/api/v3/user` API.
- This would allow anyone with a personal access token (even a read-only
  token, once scopes are implemented) to escalate their access by
  obtaining the private token.
2016-08-31 12:33:24 +05:30
Stan Hu cb8a425ba4 Fix bug where destroying a namespace would not always destroy projects
There is a race condition in DestroyGroupService now that projects are deleted asynchronously:

1. User attempts to delete group
2. DestroyGroupService iterates through all projects and schedules a Sidekiq job to delete each Project
3. DestroyGroupService destroys the Group, leaving all its projects without a namespace
4. Projects::DestroyService runs later but the can?(current_user,
   :remove_project) is `false` because the user no longer has permission to
   destroy projects with no namespace.
5. This leaves the project in pending_delete state with no namespace/group.

Projects without a namespace or group also adds another problem: it's not possible to destroy the container
registry tags, since container_registry_path_with_namespace is the wrong value.

The fix is to destroy the group asynchronously and to run execute directly on Projects::DestroyService.

Closes #17893
2016-08-11 15:36:35 -07:00