Commit a44b85be9eafed5e2aea30bbb9830e6040145c06
Exists in
master
and in
4 other branches
Merge pull request #422 from steveprentice/master
This makes gitlabhq compatible with more LDAP servers (specifically OpenLDAP).
Showing
2 changed files
with
6 additions
and
6 deletions
Show diff stats
app/controllers/omniauth_callbacks_controller.rb
@@ -2,8 +2,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController | @@ -2,8 +2,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController | ||
2 | 2 | ||
3 | def ldap | 3 | def ldap |
4 | # We only find ourselves here if the authentication to LDAP was successful. | 4 | # We only find ourselves here if the authentication to LDAP was successful. |
5 | - omniauth = request.env["omniauth.auth"]["extra"]["raw_info"] | ||
6 | - @user = User.find_for_ldap_auth(omniauth) | 5 | + info = request.env["omniauth.auth"]["info"] |
6 | + @user = User.find_for_ldap_auth(info) | ||
7 | if @user.persisted? | 7 | if @user.persisted? |
8 | @user.remember_me = true | 8 | @user.remember_me = true |
9 | end | 9 | end |
app/models/user.rb
@@ -71,15 +71,15 @@ class User < ActiveRecord::Base | @@ -71,15 +71,15 @@ class User < ActiveRecord::Base | ||
71 | name.split(" ").first unless name.blank? | 71 | name.split(" ").first unless name.blank? |
72 | end | 72 | end |
73 | 73 | ||
74 | - def self.find_for_ldap_auth(omniauth) | ||
75 | - username = omniauth.sAMAccountName[0] | ||
76 | - email = omniauth.userprincipalname[0] | 74 | + def self.find_for_ldap_auth(omniauth_info) |
75 | + name = omniauth_info.name | ||
76 | + email = omniauth_info.email | ||
77 | 77 | ||
78 | if @user = User.find_by_email(email) | 78 | if @user = User.find_by_email(email) |
79 | @user | 79 | @user |
80 | else | 80 | else |
81 | password = generate_random_password | 81 | password = generate_random_password |
82 | - @user = User.create(:name => username, | 82 | + @user = User.create(:name => name, |
83 | :email => email, | 83 | :email => email, |
84 | :password => password, | 84 | :password => password, |
85 | :password_confirmation => password | 85 | :password_confirmation => password |