Sha256: 7bbde2f7d3fba0179a6ab79e67ad009ef1c577e0d626553f169cd90da5194962
Contents?: true
Size: 863 Bytes
Versions: 13
Compression:
Stored size: 863 Bytes
Contents
module Fluent module MongoAuthParams def self.included(klass) klass.instance_eval { desc "MongoDB user" config_param :user, :string, default: nil desc "MongoDB password" config_param :password, :string, default: nil, secret: true desc "MongoDB authentication database" config_param :auth_source, :string, default: nil } end end module MongoAuth 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 end end
Version data entries
13 entries across 13 versions & 1 rubygems