Skip to content

Expose windows client authentication #1018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Mysql2::Client.new(
:ssl_mode = :disabled / :preferred / :required / :verify_ca / :verify_identity,
:default_file = '/path/to/my.cfg',
:default_group = 'my.cfg section',
:default_auth = 'authentication_windows_client'
:init_command => sql
)
```
Expand Down
10 changes: 10 additions & 0 deletions ext/mysql2/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,11 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
retval = charval;
break;

case MYSQL_DEFAULT_AUTH:
charval = (const char *)StringValueCStr(value);
retval = charval;
break;

#ifdef HAVE_CONST_MYSQL_ENABLE_CLEARTEXT_PLUGIN
case MYSQL_ENABLE_CLEARTEXT_PLUGIN:
boolval = (value == Qfalse ? 0 : 1);
Expand Down Expand Up @@ -1336,6 +1341,10 @@ static VALUE set_init_command(VALUE self, VALUE value) {
return _mysql_client_options(self, MYSQL_INIT_COMMAND, value);
}

static VALUE set_default_auth(VALUE self, VALUE value) {
return _mysql_client_options(self, MYSQL_DEFAULT_AUTH, value);
}

static VALUE set_enable_cleartext_plugin(VALUE self, VALUE value) {
#ifdef HAVE_CONST_MYSQL_ENABLE_CLEARTEXT_PLUGIN
return _mysql_client_options(self, MYSQL_ENABLE_CLEARTEXT_PLUGIN, value);
Expand Down Expand Up @@ -1437,6 +1446,7 @@ void init_mysql2_client() {
rb_define_private_method(cMysql2Client, "default_file=", set_read_default_file, 1);
rb_define_private_method(cMysql2Client, "default_group=", set_read_default_group, 1);
rb_define_private_method(cMysql2Client, "init_command=", set_init_command, 1);
rb_define_private_method(cMysql2Client, "default_auth=", set_default_auth, 1);
rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5);
rb_define_private_method(cMysql2Client, "ssl_mode=", rb_set_ssl_mode_option, 1);
rb_define_private_method(cMysql2Client, "enable_cleartext_plugin=", set_enable_cleartext_plugin, 1);
Expand Down
2 changes: 1 addition & 1 deletion lib/mysql2/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(opts = {})
opts[:connect_timeout] = 120 unless opts.key?(:connect_timeout)

# TODO: stricter validation rather than silent massaging
%i[reconnect connect_timeout local_infile read_timeout write_timeout default_file default_group secure_auth init_command automatic_close enable_cleartext_plugin].each do |key|
%i[reconnect connect_timeout local_infile read_timeout write_timeout default_file default_group secure_auth init_command automatic_close enable_cleartext_plugin default_auth].each do |key|
next unless opts.key?(key)
case key
when :reconnect, :local_infile, :secure_auth, :automatic_close, :enable_cleartext_plugin
Expand Down