Skip to content

Commit

Permalink
Report missing credentials to the Rails application.
Browse files Browse the repository at this point in the history
If no username or password is provided a MissingCredentialsError is
raised which causes a Rack caught exception and a 500 Error in gitlab.
Omniauth provides a way to raise such errors to the application by
using the 'fail!' method to pass the exception to the registered
failure handler. For gitlab this is the omniauth_controller code.

This is required to resolve gitlab issue #1077.

Signed-off-by: Pat Thoyts <[email protected]>
  • Loading branch information
patthoyts committed Jul 20, 2012
1 parent 7edf27d commit 536c321
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/omniauth/strategies/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ def request_phase
def callback_phase
@adaptor = OmniAuth::LDAP::Adaptor.new @options

# GITLAB security patch
# Dont allow blank password for ldap auth
if request['username'].nil? || request['username'].empty? || request['password'].nil? || request['password'].empty?
raise MissingCredentialsError.new("Missing login credentials")
end

begin
# GITLAB security patch
# Dont allow blank password for ldap auth
if request['username'].nil? || request['username'].empty? || request['password'].nil? || request['password'].empty?
raise MissingCredentialsError.new("Missing login credentials")
end

@ldap_user_info = @adaptor.bind_as(:filter => Net::LDAP::Filter.eq(@adaptor.uid, @options[:name_proc].call(request['username'])),:size => 1, :password => request['password'])
return fail!(:invalid_credentials) if !@ldap_user_info

Expand Down

0 comments on commit 536c321

Please sign in to comment.