Commit Graph

25 Commits

Author SHA1 Message Date
Nick Thomas 013f7cd24c
Inherit from ApplicationRecord instead of ActiveRecord::Base 2019-03-28 16:18:23 +00:00
Stan Hu ab4aba7065 Fix failed LDAP logins when nil user_id present
When a LDAP user signs in the for the first time and if there
is an `Identity` object with `user_id` of `nil`, new users
will not be able to be register until that entry is cleared
because of the way identities are created:

1. First, the User object is built but not saved, so it has no `id`.
2. Then, `user.identities.build(provider: 'ldapmain')` is called,
   but it does not have an associated `user_id` as a result.
3. `User#save` is called, but the `Identity` validation fails if an
   existing entry with `user_id` of `nil` already exists.

The uniqueness validation for `nil` values doesn't make any sense in
this case. We should be enforcing this at the database level with a
foreign key constraint. To work around the issue we can validate
against the user instead, which does the right thing even when
the user isn't saved yet.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56734
2019-01-29 11:15:06 -08:00
Yorick Peterse 9d5f921ab0
Move Identity.uniqueness_scope to a module
Moving this method to a separate module looks a bit odd, but it allows
for EE to extend the method without also having to redefine a variety of
validation rules.
2018-11-12 14:14:13 +01:00
gfyoung 50abbd3e53 Enable frozen string in app/models/*.rb
Partially addresses #47424.
2018-07-26 16:55:41 -07:00
James Edwards-Jones d14851f9a3 Backport Identity.uniqueness_scope from EE
Originates in 'SamlProvider has many linked Identities' from EE
2018-05-02 14:36:47 +01:00
Horatiu Eugen Vlad 1ad5df49b1 Moved o_auth/saml/ldap modules under gitlab/auth 2018-02-28 16:53:02 +01:00
Francisco Javier López 26af0e2d60 Fixed user synced attributes metadata after removing current provider 2018-02-15 09:27:38 +00:00
Francisco Javier López 8c6b5baba1 LDAP extern_uids are not normalized when updated via API 2017-12-21 14:31:15 +00:00
Douwe Maan 481b8a71f8 Make sure user email is read only when synced with LDAP 2017-12-15 12:48:48 +01:00
Francisco Javier López c7cf68bd6f Changing OAuth lookup to be case insensitive 2017-11-17 14:24:25 +00:00
Douwe Maan 8399de0c96 Normalize LDAP DN when looking up identity 2017-10-31 17:13:50 +01:00
Robin Bobbitt ddf7e6ae78 Implement search by extern_uid in Users API 2017-04-18 14:55:32 -04: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
Zeger-Jan van de Weg 47da013cf8 Annotate the models 2016-05-06 08:27:46 +02:00
Gabriel Mazetto ac6a10f3e8 Codestyle changes 2016-01-12 12:29:10 -02:00
Gabriel Mazetto ec67e9be1d Repair ldap_blocked state when no ldap identity exist anymore 2016-01-08 16:26:04 -02:00
Patricio Cano 1d3889eb46 Fix identity and user retrieval when special characters are used 2015-12-22 13:23:35 -05:00
Dmitriy Zaporozhets 21e227d870
Validate presence of provider field in Identity
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-23 11:21:23 +02:00
Valery Sizov 8666f497ff fix ldap identities 2015-04-11 17:56:45 +03:00
Dmitriy Zaporozhets 66c61f023b Re-annotate models 2015-03-04 14:14:00 -08:00
Dmitriy Zaporozhets 62ed1c537e Explicitly define ordering in models using default_scope 2015-02-05 14:20:55 -08:00
Dmitriy Zaporozhets e890582681 Rubocop enabled for: Use spaces inside hash literal braces 2015-02-02 20:36:54 -08:00
Dmitriy Zaporozhets 98ee4a1fa7 Annotate models 2015-01-22 09:40:03 -08:00
Valery Sizov 3a5ed5260b Supporting for multiple omniauth provider for the same user 2014-12-04 13:03:55 +02:00
Valery Sizov 1a80d13a39 Multi-provider auth. LDAP is not reworked 2014-12-04 13:01:50 +02:00