Commit Graph

171 Commits

Author SHA1 Message Date
Imre Farkas 8d900ade38
Remove PersonalAccessTokensFinder#find_by method
find_by_token is overriden by TokenAuthenticatable which can be easily
missed or confused with #find_by(:token) defined by ActiveRecord. First
step for safer usage is to remove #find_by.
2018-11-05 11:36:45 +01:00
William George 1b153d497b Make getting a user by the username case insensitive 2018-10-18 09:06:44 +00:00
Douwe Maan 9fcd903b60 Merge branch 'features/unauth-access-ssh-keys' into 'master'
List public ssh keys by id or username without authentication

See merge request gitlab-org/gitlab-ce!20118
2018-10-05 08:41:04 +00:00
Ronald Claveau 7d55c1353d List public ssh keys by id or username without authentication 2018-10-03 19:28:13 +02:00
Rémy Coutable c874a48134 Merge branch 'lib-api-frozen-string-enable' into 'master'
Enable frozen string in lib/api and lib/backup

See merge request gitlab-org/gitlab-ce!22005
2018-10-01 16:39:42 +00:00
Alexis Reigel 801fe04be7
allow users api to set public_email 2018-10-01 13:24:16 +02:00
gfyoung 3836d69119 Enable frozen string in lib/api and lib/backup
Partially addresses #47424.

Had to make changes to spec files because
stubbing methods on frozen objects is a mess
in RSpec and leads to failures:

https://github.com/rspec/rspec-mocks/issues/1190
2018-09-29 21:04:50 -07:00
Alexis Reigel 921c96ab0c
remove obsolete parameter from users api 2018-09-26 17:29:30 +02:00
Robert Speicher c7d1eef671 Merge branch 'rubocop-code-reuse' into 'master'
Add RuboCop cops to enforce code reusing rules

See merge request gitlab-org/gitlab-ce!21391
2018-09-13 14:53:05 +00:00
Yorick Peterse 2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00
Stan Hu ced2a932d7 Add ability to skip user email confirmation with API
This gives admins the ability to send a `skip_confirmation` flag in the
`POST /users/:id/email` API endpoint to skip the verification step and
assume the given e-mail address is verified.

Closes #50876
2018-09-10 22:41:53 -07: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
Marko, Peter 6d72bb3832 Add min_access_level filter to projects API
Signed-off-by: Marko, Peter <peter.marko@siemens.com>
2018-07-23 20:57:50 +02:00
Lin Jen-Shin 4ee08b77bc Updates from `rubocop -a` 2018-07-09 21:13:08 +08:00
Francisco Javier López df45623b34 Restoring user v3 endpoint 2018-06-13 08:25:01 +00: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
Markus Koller b7cd99c376
Allow including custom attributes in API responses 2018-02-08 13:30:34 +01: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
Yorick Peterse cca61980d5
Track and act upon the number of executed queries
This ensures that we have more visibility in the number of SQL queries
that are executed in web requests. The current threshold is hardcoded to
100 as we will rarely (maybe once or twice) change it.

In production and development we use Sentry if enabled, in the test
environment we raise an error. This feature is also only enabled in
production/staging when running on GitLab.com as it's not very useful to
other users.
2018-02-01 17:00:46 +01:00
Francisco Javier López 7c2b7296d4 Added default order to UserFinder 2017-12-04 09:49:53 +00:00
Daniel Juarez 0b9e1e1662 Skip confirmation user api 2017-11-21 15:47:58 +00:00
Douwe Maan fbdf057898 Remove private_token from API user entity 2017-11-02 11:39:01 +01:00
Douwe Maan 0c0c2ecd99 Merge branch 'master' into digitalmoksha/gitlab-ce-feature/verify_secondary_emails
# Conflicts:
#	app/controllers/admin/users_controller.rb
#	app/controllers/confirmations_controller.rb
#	app/controllers/profiles/emails_controller.rb
#	app/models/user.rb
#	app/services/emails/base_service.rb
#	app/services/emails/destroy_service.rb
#	app/views/devise/mailer/confirmation_instructions.html.haml
#	lib/api/users.rb
#	spec/services/emails/destroy_service_spec.rb
2017-10-05 12:48:22 +02:00
Markus Koller e9eae3eb0d Support custom attributes on users 2017-09-28 16:49:42 +00:00
James Lopez 1dcb711110 refactor emails service 2017-09-28 08:46:39 +02:00
James Lopez 67d06dee30 refactor users update service 2017-09-28 08:46:39 +02:00
James Lopez 9621dd0c9d refactor services to match EE signature 2017-09-28 08:46:39 +02: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
Brett Walker b2d5379161 fix calls to Emails::DestroyService 2017-09-23 15:24:53 +02:00
Brett Walker f9f4672275 Send a confirmation email when the user adds a secondary email address. Utilizes the Devise `confirmable` capabilities. Issue #37385 2017-09-23 15:23:11 +02:00
Robert Speicher 3cbaed97f1 Ensure we use `Entities::User` for non-admin `users/:id` API requests 2017-09-15 19:34:52 -04: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 dcd4ea473c Update remaining endpoints 2017-08-28 17:10:30 +02:00
Robert Schilling e80313f9ee Conditionally destroy a ressource 2017-08-28 16:40:25 +02:00
Robert Schilling 998afa5f74 API: Respect the 'If-Unmodified-Since' for delete endpoints 2017-08-28 16:40:25 +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
Dmitriy Zaporozhets 6b8ad689da
Update grape gem
New version of the gem returns 200 status code on delete with content
instead of 204 so we explicitly set status code to keep existing
behavior

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-07-20 16:33:18 +03: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
James Lopez 5e66c6568b fix specs 2017-07-07 16:09:30 +02:00
James Lopez 1a7d2aba3b add created at filter logic to users finder and API 2017-07-07 10:38:57 +02: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 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 ae95310523 fix spec failures 2017-06-24 10:00:23 +02:00
James Lopez 859858c7e6 fix spec failures 2017-06-23 21:13:46 +02:00