Commit Graph

163 Commits

Author SHA1 Message Date
Bob Van Landuyt 12095251c3 Add the message HTML to the UserStatus api 2018-08-01 12:42:04 +02:00
Bob Van Landuyt b4c4b48a8c Allow users to set a status
This can be done trough the API for the current user, or on the
profile page.
2018-07-30 15:01:26 +02:00
JX Terry 99011a61cf Add an option to have a private profile on GitLab 2018-07-24 12:46:19 +00:00
blackst0ne ddd2a25679 Replace 'Sidekiq::Testing.inline!' with 'perform_enqueued_jobs'
`perform_enqueued_jobs` is a Sidekiq method.
Using this method violates the Dependency inversion principle[0].

This commit replaces `perform_enqueued_jobs` with ActiveJob's abstract
method `perform_enqueued_jobs` in specs.

[0]: https://en.wikipedia.org/wiki/Dependency_inversion_principle
2018-07-23 15:34:54 +11:00
Francisco Javier López df45623b34 Restoring user v3 endpoint 2018-06-13 08:25:01 +00:00
Robert Speicher 6d165c740c Make all uses of `fixture_file_upload` use relative paths 2018-06-07 09:54:41 -05:00
Rémy Coutable 3f73b6bee0
Don't set the notification_email when only unconfirmed_email is changed
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-05-22 12:47:20 +02:00
Dmitriy Zaporozhets c87c55bb35 Add 2FA filter to users API for admins only
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2018-04-23 11:54:45 +03:00
Dmitriy Zaporozhets 28ef8cc56e
Add sorting options for /users API (admin only)
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2018-02-06 16:00:33 +02:00
Daniel Juarez 0b9e1e1662 Skip confirmation user api 2017-11-21 15:47:58 +00:00
Markus Koller 6902848a9c
Support custom attributes on projects 2017-11-06 10:51:46 +01:00
Douwe Maan 3f24f9ed18 Add sudo API scope 2017-11-02 11:39:03 +01:00
Douwe Maan 294fa6fcdc Remove authentication using user.private_token 2017-11-02 11:39:02 +01:00
Jacopo 2f40dac352 Refactor `have_http_status` into `have_gitlab_http_status` in the specs 2017-10-20 10:13:18 +02:00
Markus Koller e9eae3eb0d Support custom attributes on users 2017-09-28 16:49:42 +00:00
Tiago Botelho d70b7a490d find_user users helper method no longer overrides find_user API helper method. 2017-09-26 19:14:19 +01:00
Rémy Coutable d59255a66f
Improve the Users API specs by asserting against the response schema
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-09-18 12:15:35 +02:00
Robert Schilling 97371848c5 API: Add GPG key management for admins 2017-09-05 14:30:53 +02:00
Robert Schilling b69579742b API: Add GPG key management 2017-09-05 14:30:53 +02:00
Robert Schilling 915dd57fe2 Add tests for the unmodified header 2017-08-28 17:10:34 +02:00
Rémy Coutable 09a348eb13
Include the `is_admin` field in the `GET /users/:id` API when current user is an admin
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-11 15:14:32 +02:00
Lin Jen-Shin (godfat) 0d35b08180 Allow logged in users to read user list under public restriction 2017-08-01 07:46:13 +00:00
Lin Jen-Shin 25e44edc30 Allow admin to read_users_list even if it's restricted 2017-07-25 16:49:26 +08:00
Rémy Coutable 91f63820a5
Return `is_admin` attribute in the GET /user endpoint for admins
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-12 12:45:46 +02:00
Paul Charlton cb3b4a15e6 Support multiple Redis instances based on queue type 2017-07-11 03:35:47 +00:00
James Lopez 5e66c6568b fix specs 2017-07-07 16:09:30 +02:00
James Lopez 377244dd45 refactor filters 2017-07-07 11:38:01 +02:00
James Lopez b08df253ef add finder and users API spec 2017-07-07 10:38:57 +02:00
Timothy Andrew 94258a6500 Fix build for !12300.
- The `/users` and `/users/:id` APIs are now accessible without
  authentication (!12445), and so scopes are not relevant for these endpoints.

- Previously, we were testing our scope declaration against these two methods.
  This commit moves these tests to other `GET` user endpoints which still
  require authentication.
2017-07-05 03:44:40 +00:00
Douwe Maan 5e2f7f25eb Merge branch 'master' into '33580-fix-api-scoping'
# Conflicts:
#   lib/api/users.rb
2017-07-04 15:00:01 +00:00
Timothy Andrew d1488268b2 Simplify authentication logic in the v4 users API for !12445.
- Rather than using an explicit check to turn off authentication for the
  `/users` endpoint, simply call `authenticate_non_get!`.

- All `GET` endpoints we wish to restrict already call
  `authenticated_as_admin!`, and so remain inacessible to anonymous users.

- This _does_ open up the `/users/:id` endpoint to anonymous access. It contains
  the same access check that `/users` users, and so is safe for use here.

- More context: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12445#note_34031323
2017-07-04 12:19:48 +00:00
Timothy Andrew 5dedea358d Merge remote-tracking branch 'origin/master' into 34141-allow-unauthenticated-access-to-the-users-api
- Modify policy code to work with the `DeclarativePolicy` refactor
  in 37c401433b.
2017-06-30 13:45:51 +00:00
Timothy Andrew 3c88a7869b Implement review comments for !12445 from @godfat and @rymai.
- Use `GlobalPolicy` to authorize the users that a non-authenticated user can
  fetch from `/api/v4/users`. We allow access if the `Gitlab::VisibilityLevel::PUBLIC`
  visibility level is not restricted.

- Further, as before, `/api/v4/users` is only accessible to unauthenticated users if
  the `username` parameter is passed.

- Turn off `authenticate!` for the `/api/v4/users` endpoint by matching on the actual
  route + method, rather than the description.

- Change the type of `current_user` check in `UsersFinder` to be more
  compatible with EE.
2017-06-30 13:06:03 +00:00
Timothy Andrew 157c05f49d Test `/users` endpoints for the `read_user` scope.
- Test `GET` endpoints to check that the scope is allowed.
- Test `POST` endpoints to check that the scope is disallowed.
- Test both `v3` and `v4` endpoints.
2017-06-28 07:17:13 +00:00
Timothy Andrew 80c1ebaa83 Allow API scope declarations to be applied conditionally.
- Scope declarations of the form:

    allow_access_with_scope :read_user, if: -> (request) { request.get? }

  will only apply for `GET` requests

- Add a negative test to a `POST` endpoint in the `users` API to test this. Also
  test for this case in the `AccessTokenValidationService` unit tests.
2017-06-28 07:17:13 +00:00
Timothy Andrew 6f1922500b Initial attempt at refactoring API scope declarations.
- Declaring an endpoint's scopes in a `before` block has proved to be
  unreliable. For example, if we're accessing the `API::Users` endpoint - code
  in a `before` block in `API::API` wouldn't be able to see the scopes set in
  `API::Users` since the `API::API` `before` block runs first.

- This commit moves these declarations to the class level, since they don't need
  to change once set.
2017-06-28 07:17:13 +00:00
Timothy Andrew 20f679d620 Allow unauthenticated access to the `/api/v4/users` API.
- The issue filtering frontend code needs access to this API for non-logged-in
  users + public projects. It uses the API to fetch information for a user by
  username.

- We don't authenticate this API anymore, but instead - if the `current_user` is
  not present:

  - Verify that the `username` parameter has been passed. This disallows an
    unauthenticated user from grabbing a list of all users on the instance. The
    `UsersFinder` class performs an exact match on the `username`, so we are
    guaranteed to get 0 or 1 users.
  - Verify that the resulting user (if any) is accessible to be viewed publicly
    by calling `can?(current_user, :read_user, user)`
2017-06-26 07:20:30 +00:00
James Lopez c9fd3dc42c more refactoring based on feedback 2017-06-23 11:41:42 +02:00
James Lopez ef6a4240e5 update notification settings, fix api specs 2017-06-23 11:41:41 +02:00
James Lopez 5f0e7873ae ported EE user service to CE 2017-06-23 11:41:41 +02:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Mike Ricketts 0e7478064f Re-instate is_admin flag in users API is current user is an admin 2017-06-20 14:54:29 +00:00
vanadium23 83a9a472b3 Accept image for avatar in user API 2017-06-16 23:52:15 +03:00
Robert Speicher a6ec5121f0 Correct RSpec/SingleLineHook cop offenses 2017-06-14 13:18:56 -05:00
Grzegorz Bizon eebd18c3ac Merge branch '2563-backport-ee1942' into 'master'
Backport some EE changes from adding shared_runners_minutes_limit to the API

Closes gitlab-ee#2563

See merge request !11936
2017-06-07 07:04:21 +00:00
Lin Jen-Shin d919f924bf Backport https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1942 2017-06-06 21:42:45 +08:00
Mark Fletcher ad3e180ed3 Introduce an Events API
* Meld the following disparate endpoints:
 * `/projects/:id/events`
 * `/events`
 * `/users/:id/events`
+ Add result filtering to the above endpoints:
 * action
 * target_type
 * before and after dates
2017-06-06 20:16:41 +08:00
Nick Thomas c890c6aaf2 Allow users to be hard-deleted from the API 2017-06-02 18:28:12 +01:00
Douwe Maan 43b1750892 Revert "Remove changes that are not absolutely necessary"
This reverts commit b0498c176f
2017-05-24 20:59:26 +00:00
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