Module: Fluent::MongoAuth

Included in:
Plugin::MongoOutput, Plugin::MongoTailInput
Defined in:
lib/fluent/plugin/mongo_auth.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(client) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fluent/plugin/mongo_auth.rb', line 16

def authenticate(client)
  unless @user.nil? || @password.nil?
    begin
      if @auth_source.nil?
        client = client.with(user: @user, password: @password)
      else
        client = client.with(user: @user, password: @password, auth_source: @auth_source)
      end
    rescue Mongo::Auth::Unauthorized => e
      log.fatal e
      exit!
    end
  end
  client
end