A user which is created in Gitlab after LDAP sign in cannot sign in again
Installation details:
- Gitlab 8.0.4 installed in Docker
- Completely fresh installation with only
root
user.
Problem description:
I have a user with username bstinson
which is automatically created in Gitlab when he logs in using LDAP authentication. This is the output of gitlab-rails/application.log
:
October 21, 2015 12:44: User "Barney Stinson" (bstinson@gna.com) was created
October 21, 2015 12:44: (OAuth) saving user Bstinson@gna.com from login with extern_uid => CN=Barney Stinson,OU=Dev Users,OU=Development,DC=gna,DC=local
When this user logs out and tries to sign in again, the "Sign in" form shows the error:
Could not authorize you from Ldapmain because "Undefined method `provider' for nil:nilclass".
and gitlab-rails/application.log
shows:
October 21, 2015 12:47: (OAuth) Error saving user: ["Email has already been taken", "Identities extern uid has already been taken"]
and gitlab-rails/production.log
shows:
Started POST "/users/auth/ldapmain/callback" for 127.0.0.1 at 2015-10-21 12:47:24 +0300
Processing by OmniauthCallbacksController#ldapmain as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "username"=>"bstinson", "password"=>"[FILTERED]"}
Completed 500 Internal Server Error in 276ms (ActiveRecord: 23.5ms)
My LDAP configuration is the following:
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS' # remember to close this block with 'EOS' below
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: '192.168.10.2'
port: 389
uid: 'sAMAccountName'
method: 'plain' # "tls" or "ssl" or "plain"
bind_dn: 'CN=admin,OU=Dev Users,OU=Development,DC=gna,DC=local'
password: 'mypass'
active_directory: true
allow_username_or_email_login: false
block_auto_created_users: false
base: 'dc=gna,dc=local'
user_filter: ''
attributes:
username: ['sAMAccountName']
email: ['mail', 'email', 'userPrincipalName']
Concerning the database, I connect using psql and the results of users table entry is:
gitlabhq_production=# select * from users where username like '%bstinson%';
-[ RECORD 1 ]--------------+----------------------------------------------------
---------
id | 8
email | bstinson@gnb.com
encrypted_password | $2a$1rWL15b0of0vdPe4GHeN7cBGn4/.85nUhS1Bbr
g3jcpGTw.
reset_password_token |
reset_password_sent_at |
remember_created_at |
sign_in_count | 1
current_sign_in_at | 2015-10-21 09:44:23.49429
last_sign_in_at | 2015-10-21 09:44:23.49429
current_sign_in_ip | 127.0.0.1
last_sign_in_ip | 127.0.0.1
created_at | 2015-10-21 09:44:23.070246
updated_at | 2015-10-21 09:47:16.207773
name | Barney Stinson
admin | f
projects_limit | 10
skype |
linkedin |
twitter |
authentication_token | uoc413too2PKkVMBFqLw
theme_id | 2
bio |
failed_attempts | 0
locked_at |
username | bstinson1
can_create_group | t
can_create_team | f
state | active
color_scheme_id | 1
notification_level | 1
password_expires_at |
created_by_id |
last_credential_check_at | 2015-10-21 09:44:23.37368
avatar |
confirmation_token |
confirmed_at | 2015-10-21 09:44:22.459343
confirmation_sent_at |
unconfirmed_email |
hide_no_ssh_key | f
website_url |
notification_email | bstinson@gnb.com
hide_no_password | f
password_automatically_set | t
location |
encrypted_otp_secret |
encrypted_otp_secret_iv |
encrypted_otp_secret_salt |
otp_required_for_login | f
otp_backup_codes | null
public_email |
dashboard | 0
project_view | 0
consumed_timestep |
and identities table entry for this user is:
gitlabhq_production=# select * from identities;
-[ RECORD 1 ]----------------------------------------------------------------------------
id | 7
extern_uid | CN=Barney Stinson,OU=Dev Users,OU=Development,DC=gna,DC=local
provider | ldapmain
user_id | 8
created_at | 2015-10-21 09:44:23.094698
updated_at | 2015-10-21 09:44:23.094698
As far as I can see, everytime the user tries to sign in via LDAP the following happen:
- Gitlab tries to recreate the user.
- An integer is appended after username, so "bstinson" becomes "bstinson1"
- I have run
sudo gitlab-rake gitlab:check
, and it shows no errors.
I have searched for other issues having the same problem using this query but I could not find any issue similar to mine ... I have read and tried all possible solutions described in issues #993,#1875,#1964,#946.
Is there something I am missing?
Thank you in advance,
Christos