Commit fea591e5 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Rename finder to find_in_gitlab_or_ldap

parent 8299fc27
...@@ -12,7 +12,7 @@ Doorkeeper.configure do ...@@ -12,7 +12,7 @@ Doorkeeper.configure do
end end
resource_owner_from_credentials do |routes| resource_owner_from_credentials do |routes|
Gitlab::Auth.find_by_master_or_ldap(params[:username], params[:password]) Gitlab::Auth.find_in_gitlab_or_ldap(params[:username], params[:password])
end end
# If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below. # If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
......
...@@ -11,7 +11,7 @@ module API ...@@ -11,7 +11,7 @@ module API
# Example Request: # Example Request:
# POST /session # POST /session
post "/session" do post "/session" do
user = Gitlab::Auth.find_by_master_or_ldap(params[:email] || params[:login], params[:password]) user = Gitlab::Auth.find_in_gitlab_or_ldap(params[:email] || params[:login], params[:password])
return unauthorized! unless user return unauthorized! unless user
present user, with: Entities::UserLogin present user, with: Entities::UserLogin
......
...@@ -9,7 +9,7 @@ module Gitlab ...@@ -9,7 +9,7 @@ module Gitlab
if valid_ci_request?(login, password, project) if valid_ci_request?(login, password, project)
type = :ci type = :ci
elsif user = find_by_master_or_ldap(login, password) elsif user = find_in_gitlab_or_ldap(login, password)
type = :master_or_ldap type = :master_or_ldap
elsif user = oauth_access_token_check(login, password) elsif user = oauth_access_token_check(login, password)
type = :oauth type = :oauth
...@@ -19,7 +19,7 @@ module Gitlab ...@@ -19,7 +19,7 @@ module Gitlab
[user, type] [user, type]
end end
def find_by_master_or_ldap(login, password) def find_in_gitlab_or_ldap(login, password)
user = User.by_login(login) user = User.by_login(login)
# If no user is found, or it's an LDAP server, try LDAP. # If no user is found, or it's an LDAP server, try LDAP.
......
...@@ -95,7 +95,7 @@ module Grack ...@@ -95,7 +95,7 @@ module Grack
end end
def authenticate_user(login, password) def authenticate_user(login, password)
user = Gitlab::Auth.new.find_by_master_or_ldap(login, password) user = Gitlab::Auth.new.find_in_gitlab_or_ldap(login, password)
unless user unless user
user = oauth_access_token_check(login, password) user = oauth_access_token_check(login, password)
......
...@@ -41,7 +41,7 @@ describe Gitlab::Auth, lib: true do ...@@ -41,7 +41,7 @@ describe Gitlab::Auth, lib: true do
end end
end end
describe 'find_by_master_or_ldap' do describe 'find_in_gitlab_or_ldap' do
let!(:user) do let!(:user) do
create(:user, create(:user,
username: username, username: username,
...@@ -52,25 +52,25 @@ describe Gitlab::Auth, lib: true do ...@@ -52,25 +52,25 @@ describe Gitlab::Auth, lib: true do
let(:password) { 'my-secret' } let(:password) { 'my-secret' }
it "should find user by valid login/password" do it "should find user by valid login/password" do
expect( gl_auth.find_by_master_or_ldap(username, password) ).to eql user expect( gl_auth.find_in_gitlab_or_ldap(username, password) ).to eql user
end end
it 'should find user by valid email/password with case-insensitive email' do it 'should find user by valid email/password with case-insensitive email' do
expect(gl_auth.find_by_master_or_ldap(user.email.upcase, password)).to eql user expect(gl_auth.find_in_gitlab_or_ldap(user.email.upcase, password)).to eql user
end end
it 'should find user by valid username/password with case-insensitive username' do it 'should find user by valid username/password with case-insensitive username' do
expect(gl_auth.find_by_master_or_ldap(username.upcase, password)).to eql user expect(gl_auth.find_in_gitlab_or_ldap(username.upcase, password)).to eql user
end end
it "should not find user with invalid password" do it "should not find user with invalid password" do
password = 'wrong' password = 'wrong'
expect( gl_auth.find_by_master_or_ldap(username, password) ).not_to eql user expect( gl_auth.find_in_gitlab_or_ldap(username, password) ).not_to eql user
end end
it "should not find user with invalid login" do it "should not find user with invalid login" do
user = 'wrong' user = 'wrong'
expect( gl_auth.find_by_master_or_ldap(username, password) ).not_to eql user expect( gl_auth.find_in_gitlab_or_ldap(username, password) ).not_to eql user
end end
context "with ldap enabled" do context "with ldap enabled" do
...@@ -81,13 +81,13 @@ describe Gitlab::Auth, lib: true do ...@@ -81,13 +81,13 @@ describe Gitlab::Auth, lib: true do
it "tries to autheticate with db before ldap" do it "tries to autheticate with db before ldap" do
expect(Gitlab::LDAP::Authentication).not_to receive(:login) expect(Gitlab::LDAP::Authentication).not_to receive(:login)
gl_auth.find_by_master_or_ldap(username, password) gl_auth.find_in_gitlab_or_ldap(username, password)
end end
it "uses ldap as fallback to for authentication" do it "uses ldap as fallback to for authentication" do
expect(Gitlab::LDAP::Authentication).to receive(:login) expect(Gitlab::LDAP::Authentication).to receive(:login)
gl_auth.find_by_master_or_ldap('ldap_user', 'password') gl_auth.find_in_gitlab_or_ldap('ldap_user', 'password')
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment