def initialize(options)
@database = options[:database] || Database::ADMIN
@auth_source = options[:auth_source] || @database
@name = options[:user]
@password = options[:password] || options[:pwd]
@mechanism = options[:auth_mech]
if @mechanism
unless @mechanism.is_a?(Symbol)
if Lint.enabled?
raise Error::LintError, "Auth mechanism #{@mechanism.inspect} must be specified as a symbol"
else
log_warn("Auth mechanism #{@mechanism.inspect} should be specified as a symbol")
@mechanism = @mechanism.to_sym
end
end
unless Auth::SOURCES.key?(@mechanism)
raise InvalidMechanism.new(options[:auth_mech])
end
end
@auth_mech_properties = options[:auth_mech_properties] || {}
@roles = options[:roles] || []
@client_key = options[:client_key]
end