481 Commits
Author SHA1 Message Date
Dravere a0a9494e4e Added setting to set new users by default as external
As requested by the issue #14508 this adds an option in the application
settings to set newly registered users by default as external. The
default setting is set to false to stay backward compatible.
2016-07-07 19:21:18 +02:00
Robert Speicher c7b68b6e66 Dumb-down avatar presence check in avatar_url methods
`avatar.present?` goes through CarrierWave, and checks that the file
exists on disk and checks its filesize. Because we're hitting the disk,
this adds extra overhead to something where the worst-case scenario is
rendering a broken image.

Instead, we now just check that the _database attribute_ is present,
which is good enough for our purposes.

See https://gitlab.com/gitlab-org/gitlab-ce/issues/19273
2016-07-05 10:51:11 -04:00
Grzegorz Bizon 9e211091a8 Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
Grzegorz Bizon 28bafd5354 Enable Style/SpaceAfterComma Rubocop cop 2016-06-29 15:23:44 +02:00
James Lopez 31c95aa031 add missing attribute to attr_encrypted so it is fully backwards-compatible 2016-06-28 09:55:19 +02:00
Rémy Coutable aec3475df9 Fix an information disclosure when requesting access to a group containing private projects
The issue was with the `User#groups` and `User#projects` associations
which goes through the `User#group_members` and `User#project_members`.

Initially I chose to use a secure approach by storing the requester's
user ID in `Member#created_by_id` instead of `Member#user_id` because I
was aware that there was a security risk since I didn't know the
codebase well enough.

Then during the review, we decided to change that and directly store the
requester's user ID into `Member#user_id` (for the sake of simplifying
the code I believe), meaning that every `group_members` / `project_members`
association would include the requesters by default...

My bad for not checking that all the `group_members` / `project_members`
associations and the ones that go through them (e.g. `Group#users` and
`Project#users`) were made safe with the `where(requested_at: nil)` /
`where(members: { requested_at: nil })` scopes.

Now they are all secure.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-24 12:01:48 +02:00
Nathan Bush 64883faa6e Fix user creation with stronger minimum password requirements:q 2016-06-23 11:52:05 -04:00
Paco Guzman 208b18c956 Unify check branch name exist 2016-06-20 21:44:21 +02:00
Paco Guzman f6bfa46daa Cache todo counters (pending/done)
- As todos are created/updated inside the TodoService
we repopulate the cache just there for both pending/done todos
- Todos as mark as done from the TodosController we update cache
there too
- All the added methods are kept in the User class for cohesion
2016-06-17 19:04:36 +02:00
Timothy Andrew 90bba2bc46 Merge remote-tracking branch 'origin/master' into 2979-personal-access-tokens 2016-06-16 08:27:37 +05:30
Timothy Andrew 7ee0898a9e Implement @DouweM's feedback.
- Extract a duplicated `redirect_to`
- Fix a typo: "token", not "certificate"
- Have the "Expires at" datepicker be attached to a text field, not inline
- Have both private tokens and personal access tokens verified in a
  single "authenticate_from_private_token" method, both in the
  application and API. Move relevant logic to
  `User#find_by_personal_access_token`
- Remove unnecessary constants relating to API auth. We don't need a
  separate constant for personal access tokens since the param is the
  same as for private tokens.
2016-06-16 08:24:13 +05:30
Rémy Coutable d26f81239a Add request access for groups
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-14 13:07:26 +02:00
Timothy Andrew d0bcba1105 Merge remote-tracking branch 'origin/master' into 2979-personal-access-tokens 2016-06-14 09:06:53 +05:30
Douglas Barbosa Alexandre 1491767583 Use Issue.visible_to_user in Notes.search to avoid query duplication 2016-06-13 19:32:00 -03:00
Douglas Barbosa Alexandre b56c456750 Project members with guest role can't access confidential issues 2016-06-13 19:32:00 -03:00
Felipe Artur 39ead205de Remove notification level fild from users, improve migrations and specs 2016-06-10 11:49:30 -03:00
Felipe Artur 8f6d43e0fe Remove notification level from user model 2016-06-10 10:58:13 -03:00
Timothy Andrew 1779d68bfe Merge remote-tracking branch 'origin/master' into 2979-personal-access-tokens 2016-06-09 14:40:14 +05:30
Timothy Andrew 791cc9138b Add a U2fRegistrations table/model.
- To hold registrations from U2F devices, and to authenticate them.
- Previously, `User#two_factor_enabled` was aliased to the
  `otp_required_for_login` column on `users`.
- This commit changes things a bit:
    - `User#two_factor_enabled` is not a method anymore
    - `User#two_factor_enabled?` checks both the
      `otp_required_for_login` column, as well as `U2fRegistration`s
    - Change all instances of `User#two_factor_enabled` to
      `User#two_factor_enabled?`
- Add the `u2f` gem, and implement registration/authentication at the
  model level.
2016-06-06 12:50:31 +05:30
Z.J. van de Weg 9d491712cf Merge branch 'master' into awardables 2016-06-03 15:20:11 +02:00
Timothy Andrew ae0d8222af Merge remote-tracking branch 'origin/master' into 2979-personal-access-tokens 2016-06-03 09:31:16 +05:30
Josh Frye 8835b7889a Flush cache in callback. Add tests 2016-06-02 09:13:59 -04:00
Josh Frye bfccea3703 Cache assigned open issue count. Closes #18035 2016-06-02 09:13:59 -04:00
Josh Frye bffe0d6325 Cache assigned merge request count. Closes #18036 2016-06-02 09:13:59 -04:00
Connor Shea d287315dbf Upgrade attr_encrypted and encryptor
attr_encrypted (1.3.4 => 3.0.1) Changelog:
https://github.com/attr-encrypted/attr_encrypted/blob/master/CHANGELOG.m
d

attr_encrypted 2.x included a vulnerability, so that major version is
skipped. 3.x requires that the algorithm and mode used by each
encrypted attribute is specified explicitly.

`nil` is no longer a valid value for the encrypted_value_iv field, so
it’s changed to a randomly generated string.
2016-05-30 13:51:21 -06:00
Connor Shea d47b2b92c9 Upgrade devise and devise-two-factor, remove devise-async
Devise (3.5.4 => 4.1.1) Changelog:
https://github.com/plataformatec/devise/blob/master/CHANGELOG.md

devise-two-factor (2.0.1 => 3.0.0) Changelog:
https://github.com/tinfoil/devise-two-factor/blob/master/CHANGELOG.md

These are reliant on each other, so they have to be upgraded together.

devise-async is no longer necessary as Devise 4.1 fixes a bug with the
ActiveJob integration.
2016-05-30 13:51:21 -06:00
ZJ van de Weg 7ae536002a Merge branch 'master' into awardables 2016-05-25 14:41:25 +02:00
Stan Hu d46e47a5b6 Revert "Merge branch 'issues/15127' into 'master'"
This reverts merge request !3647
2016-05-19 14:09:24 +00:00
Stan Hu 3656b5db07 Merge branch 'issues/15127' into 'master'
fix #15127 ActiveJob::DeserializationError thrown

`send_devise_notification` pre-maturely enqueued the task when the user instance
has not yet been committed into the database, causing a record-not-found in the
other sidekiq process.

`devise-async` has already been taking care of asynchronous mail sending, we just
need to run it inside queue `mailers` instead of `mailer` to enable it.

The implementation of `devise-async` enqueues the task in `after_commit` hook
which is the right way to do it.

See merge request !3647
2016-05-19 06:12:34 +00:00
Rémy Coutable b340ca356a Remove User#tm_in_authorized_projects and User#tm_of
These methods seems to be unused.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-05-18 13:43:33 -05:00
Fatih Acet bb883387f9 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into awardables
# Conflicts:
#	app/controllers/projects/merge_requests_controller.rb
#	app/models/note.rb
#	db/schema.rb
#	spec/models/note_spec.rb
2016-05-18 13:05:53 -05:00
Felipe Artur 0baadd6cff Fix changelog file 2016-05-16 14:56:32 -03:00
Felipe Artur c5526a2d9a Change skip_user_confirmation_email to send_user_confirmation_email 2016-05-16 14:56:32 -03:00
Felipe Artur 71ca2de7aa Toggle email signup confirmation in admin settings 2016-05-16 14:56:32 -03:00
Zeger-Jan van de Weg 4558b5b9fe Incorporate feedback 2016-05-11 22:43:58 +02:00
Zeger-Jan van de Weg 2f0d89ecff Merge branch 'master' into awardables 2016-05-11 22:34:25 +02:00
Sean McGivern acd8930c46 Tidy up user project specs 2016-05-11 09:03:23 +01:00
Zeger-Jan van de Weg 7e6dcf9cd0 Merge branch 'master' into awardables 2016-05-11 08:47:04 +02:00
Timothy Andrew 2e9742997d Merge remote-tracking branch 'origin/master' into 2979-personal-access-tokens 2016-05-11 09:52:58 +05:30
Sean McGivern 97424ea544 Restrict starred projects to viewable ones
`User#starred_projects` doesn't perform any visibility checks. This has
a couple of problems:

1. It assumes a user can always view all of their starred projects in
   perpetuity (project not changed to private, access revoked, etc.).
2. It assumes that we'll only ever allow a user to star a project they
   can view. This is currently the case, but bugs happen.

Add `User#viewable_starred_projects` to filter the starred projects by
those the user either has explicit access to, or are public or
internal. Then use that in all places where we list the user's starred
projects.
2016-05-10 18:13:52 +01:00
Jeroen van Baarsen f1479b56b7 Remove the annotate gem and delete old annotations
In 8278b763d9 the default behaviour of annotation
has changes, which was causing a lot of noise in diffs. We decided in #17382
that it is better to get rid of the whole annotate gem, and instead let people
look at schema.rb for the columns in a table.

Fixes: #17382
2016-05-09 18:00:28 +02:00
Rémy Coutable bdfe6dc319 Merge branch 'fix-secret' into 'master'
Don't read otp_secret_encryption_key from hardcoded path in models/user

Variable `Gitlab::Application.config.secret_key_base` is set in config/initializers/secret_token.rb. It's very bad practice to use hard-coded paths inside an application and really unnecessary in this case.

Mirror of https://github.com/gitlabhq/gitlabhq/pull/10311

See merge request !4044
2016-05-09 14:17:33 +00:00
Zeger-Jan van de Weg 3bdc57f0a7 Create table for award emoji 2016-05-06 10:47:11 +02:00
Zeger-Jan van de Weg 47da013cf8 Annotate the models 2016-05-06 08:27:46 +02:00
Jakub Jirutka e4c64855e8 Don't read otp_secret_encryption_key from hardcoded path in models/user
Variable `Gitlab::Application.config.secret_key_base` is set in
config/initializers/secret_token.rb. It's very bad practice to use
hard-coded paths inside an application and really unnecessary in this
case.
2016-05-04 23:09:47 +02:00
Connor Shea 3004386b55 Revert "Remove the Devise Async gem."
This reverts commit 1cc614f2bd.

It was causing the ActiveJob integration to fail, so unfortunately we'll have to add the gem again.
2016-05-03 15:43:51 -06:00
Timothy Andrew 3a60903874 Allow creating Personal Access Tokens through the website. 2016-04-28 22:28:36 +05:30
Connor Shea 1cc614f2bd Remove the Devise Async gem.
The extra gem isn’t necessary anymore since Rails 4.2 has ActiveJob integration.

Resolves #15575.
2016-04-26 10:41:48 -06:00
Rémy Coutable 1fbea7cec9 Remove useless require 'file_size_validator' causing warnings
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-04-19 11:40:16 +02:00
P.S.V.R e4d9d4e55b fix #15127 ActiveJob::DeserializationError thrown
send_devise_notification pre-maturely enqueued the task when the user instance
has not yet been committed into the database, causing a record-not-found in the
other sidekiq process.

devise-async has already been taking care of asynchronous mail sending, we just
need to run it inside queue `mailers` instead of `mailer` to enable it.
2016-04-11 16:45:00 +08:00