lib/mongo/uri.rb in mongo-2.11.0.rc0 vs lib/mongo/uri.rb in mongo-2.11.0
- old
+ new
@@ -239,11 +239,14 @@
#
# @return [ Mongo::Options::Redacted ] The options passed to the Mongo::Client
#
# @since 2.0.0
def client_options
- opts = default_client_options.merge(uri_options)
+ opts = uri_options.tap do |opts|
+ opts[:database] = @database if @database
+ end
+
@user ? opts.merge(credentials) : opts
end
def srv_records
nil
@@ -440,39 +443,10 @@
def parse_database!(string)
raise_invalid_error!(UNESCAPED_DATABASE) if string =~ UNSAFE
decode(string) if string.length > 0
end
- def default_client_options
- opts = Options::Redacted.new(database: database)
-
- if @uri_options[:auth_mech] || @user
- opts[:auth_source] = default_auth_source
- end
-
- if @uri_options[:auth_mech] == :gssapi
- opts[:auth_mech_properties] = default_auth_mech_properties
- end
-
- opts
- end
-
- def default_auth_mech_properties
- { service_name: 'mongodb' }
- end
-
- def default_auth_source
- case @uri_options[:auth_mech]
- when :gssapi, :mongodb_x509
- :external
- when :plain
- @database || :external
- else
- @database || Database::ADMIN
- end
- end
-
def raise_invalid_error!(details)
raise Error::InvalidURI.new(@string, details, FORMAT)
end
def raise_invalid_error_no_fmt!(details)
@@ -542,11 +516,11 @@
# Topology options
uri_option 'connect', :connect, type: :symbol
# Auth Options
- uri_option 'authsource', :auth_source, :type => :auth_source
+ uri_option 'authsource', :auth_source
uri_option 'authmechanism', :auth_mech, :type => :auth_mech
uri_option 'authmechanismproperties', :auth_mech_properties, :type => :auth_mech_props
# Client Options
uri_option 'appname', :app_name
@@ -628,19 +602,9 @@
end
target = select_target(uri_options, strategy[:group])
value = apply_transform(key, value, strategy[:type])
merge_uri_option(target, value, strategy[:name])
- end
-
- # Auth source transformation, either db string or :external.
- #
- # @param value [String] Authentication source.
- #
- # @return [String] If auth source is database name.
- # @return [:external] If auth source is external authentication.
- def auth_source(value)
- value == '$external' ? :external : value
end
# Authentication mechanism transformation.
#
# @param value [String] The authentication mechanism.