Skip to content

Commit 91f6c1b

Browse files
committed
Add secure_auth mysql_option()
1 parent 7ca5f1f commit 91f6c1b

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Mysql2::Client.new(
108108
:connect_timeout = seconds,
109109
:reconnect = true/false,
110110
:local_infile = true/false,
111+
:secure_auth = true/false
111112
)
112113
```
113114

ext/mysql2/client.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,11 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
716716
retval = &boolval;
717717
break;
718718

719+
case MYSQL_SECURE_AUTH:
720+
boolval = (value == Qfalse ? 0 : 1);
721+
retval = &boolval;
722+
break;
723+
719724
default:
720725
return Qfalse;
721726
}
@@ -1085,6 +1090,10 @@ static VALUE set_ssl_options(VALUE self, VALUE key, VALUE cert, VALUE ca, VALUE
10851090
return self;
10861091
}
10871092

1093+
static VALUE set_secure_auth(VALUE self, VALUE value) {
1094+
return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
1095+
}
1096+
10881097
static VALUE initialize_ext(VALUE self) {
10891098
GET_CLIENT(self);
10901099

@@ -1153,6 +1162,7 @@ void init_mysql2_client() {
11531162
rb_define_private_method(cMysql2Client, "write_timeout=", set_write_timeout, 1);
11541163
rb_define_private_method(cMysql2Client, "local_infile=", set_local_infile, 1);
11551164
rb_define_private_method(cMysql2Client, "charset_name=", set_charset_name, 1);
1165+
rb_define_private_method(cMysql2Client, "secure_auth=", set_secure_auth, 1);
11561166
rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5);
11571167
rb_define_private_method(cMysql2Client, "initialize_ext", initialize_ext, 0);
11581168
rb_define_private_method(cMysql2Client, "connect", rb_connect, 7);

lib/mysql2/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def initialize(opts = {})
2222
initialize_ext
2323

2424
# Set MySQL connection options (each one is a call to mysql_options())
25-
[:reconnect, :connect_timeout, :local_infile, :read_timeout, :write_timeout].each do |key|
25+
[:reconnect, :connect_timeout, :local_infile, :read_timeout, :write_timeout, :secure_auth].each do |key|
2626
next unless opts.key?(key)
2727
case key
28-
when :reconnect, :local_infile
28+
when :reconnect, :local_infile, :secure_auth
2929
send(:"#{key}=", !!opts[key])
3030
when :connect_timeout, :read_timeout, :write_timeout
3131
send(:"#{key}=", opts[key].to_i)

0 commit comments

Comments
 (0)