Sha256: 49937b164c39d008bd40fa0a74612519b64836d83a0337f50530ac770b0eac73
Contents?: true
Size: 1.07 KB
Versions: 5
Compression:
Stored size: 1.07 KB
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 desc "MongoDB authentication mechanism" config_param :auth_mech, :string, default: nil } end end module MongoAuth def authenticate(client) begin if [@user, @password, @auth_source].all? client = client.with(user: @user, password: @password, auth_source: @auth_source) elsif [@user, @password].all? client = client.with(user: @user, password: @password) elsif [@user, @auth_source, @auth_mech].all? client = client.with(user: @user, auth_source: @auth_source, auth_mech: @auth_mech.to_sym) end rescue Mongo::Auth::Unauthorized => e log.fatal e exit! end client end end end
Version data entries
5 entries across 5 versions & 1 rubygems