Req #68281 [Com]: mariadb server with dialog auth method

From: Date: Wed, 22 Oct 2014 06:13:44 +0000
Subject: Req #68281 [Com]: mariadb server with dialog auth method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188250@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68281&edit=1

 ID:                 68281
 Comment by:         roberto at spadim dot com dot br
 Reported by:        roberto at spadim dot com dot br
 Summary:            mariadb server with dialog auth method
 Status:             Open
 Type:               Feature/Change Request
 Package:            MySQL related
 Operating System:   any
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

what kinds of questions exists:

https://github.com/MariaDB/server/blob/e974b564389af8251c2ba51060e6129e45431586/include/mysql/auth_dialog_client.h


Previous Comments:
------------------------------------------------------------------------
[2014-10-22 06:12:14] roberto at spadim dot com dot br

more example from mariadb server:

https://github.com/MariaDB/server/blob/1e79138459038c39c85239a825bf1727ef43c156/client/mysql.cc#L4500

------------------------------------------------------------------------
[2014-10-22 06:08:56] roberto at spadim dot com dot br

here more info about how to use dialog and client:

https://github.com/MariaDB/server/blob/10.1/plugin/auth_dialog/dialog.c
/*
  This plugin performs a dialog with the user, asking questions and
  reading answers. Depending on the client it may be desirable to do it
  using GUI, or console, with or without curses, or read answers
  from a smartcard, for example.

  To support all this variety, the dialog plugin has a callback function
  >>>>>"authentication_dialog_ask"<<<<<. If the client has a
  >>>>>function of this name
  dialog plugin will use it for communication with the user. Otherwise
  a default implementation will be used.
*/

------------------------------------------------------------------------
[2014-10-22 05:58:53] roberto at spadim dot com dot br

Description:
------------
Hi guys, i'm testing mysql connect with a mariadb server using a dialog auth plugin (server
side)

i didn't found functions to execute dialog with server

a full example of what i want but using heidisql can be found here:
http://www.heidisql.com/forum.php?t=9752

---
here the php files (download only .php files):
https://github.com/rspadim/server/blob/otp_plugin/plugin/auth_otp/
here the today output using mysql_connect: (using otp_auth_example.php php file)

==============================
MYSQL_CONNECT:

PHP Warning:  mysql_connect(): The server requested authentication
method unknown to the client [dialog] in
C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_e
xample.php on line 50

Warning: mysql_connect(): The server requested authentication method
unknown to the client [dialog] in
C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_exampl
e.php on line 50
PHP Warning:  mysql_connect(): The server requested authentication
method umknown to the client in
C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_example.ph
p on line 50

Warning: mysql_connect(): The server requested authentication method
umknown to the client in
C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_example.php on
line 50
Error: The server requested authentication method >>>umknown<<< to the
client   (CHECK A TYPO ERROR)


==============================
MYSQI_CONNECT:
C:\GIT\mariadb-tmp\server\plugin\auth_otp>php otp_auth_example.php
PHP Warning:  mysqli_connect(): The server requested authentication
method unknown to the client [dialog] in
C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_
example.php on line 60

Warning: mysqli_connect(): The server requested authentication method
unknown to the client [dialog] in
C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_examp
le.php on line 60
PHP Warning:  mysqli_connect(): (HY000/2054): The server requested
authentication method umknown to the client in
C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_
auth_example.php on line 60

Warning: mysqli_connect(): (HY000/2054): The server requested
authentication method umknown to the client in
C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_
example.php on line 60
PHP Warning:  mysqli_error() expects parameter 1 to be mysqli, boolean
given in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_example.php
on line 62

Warning: mysqli_error() expects parameter 1 to be mysqli, boolean
given in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_example.php
on line 62
Error:




===============================
PDO:

C:\GIT\mariadb-tmp\server\plugin\auth_otp>php otp_auth_example.php
PHP Warning:  PDO::__construct(): The server requested authentication
method unknown to the client [dialog] in
C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_aut
h_example.php on line 68

Warning: PDO::__construct(): The server requested authentication
method unknown to the client [dialog] in
C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_exa
mple.php on line 68
Error: SQLSTATE[HY000] [2054] The server requested authentication
method umknown to the client

Test script:
---------------
https://github.com/rspadim/server/blob/otp_plugin/plugin/auth_otp/

download all .php files
otp_auth_example.php 

at mariadb server:
INSTALL PLUGIN three_attempts SONAME 'dialog_examples.so';
CREATE USER test_dialog IDENTIFIED VIA three_attempts USING 'SECRET';

try to connect using username = test_dialog, and password='SECRET'

Expected result:
----------------
implement a new feature of dialog connection

three functions must be implemented for <mysql> and <mysqli> extension:
mysql_auth_dialog_received()
mysql_auth_dialog_receive()
mysql_auth_dialog_send()

and maybe at mysql_connect we will need a parameter to call a mysql function, for example

$link = mysql_connect($HOST, $USER, $PASSWORD);
if(mysql_auth_dialog_received($link)){
  $tmp=mysql_auth_dialog_receive($link); /*
array(type=>'pass/text',message=>'any message') */
  mysql_auth_dialog_send($link,"any message");
}
if($link){
  // ok good connection
}else{
  // die("can't connect");
}

-------------

with mysqli we could use mysqli_init, mysqli_options, mysqli_realconnect

$db = mysqli_init(); 
$test = $db->options(MYSQLI_DIALOG_FUNCTION,function(){}); 
or
$test = $db->options(MYSQLI_DIALOG_FUNCTION,"an_callback_function"); 
function an_callback_function($db,$type,$message){
  return true; /* wait other message */
  return false; /* disconnect */
  mysqli_auth_dialog_send($db,"message");
}


------------
PDO:
$dbh = new PDO("mysql:host=$HOST;port=$HOST_PORT;dbname=$DB", $USER, $PASSWORD, array(
"MYSQL_DIALOG_AUTH_CALLBACK_FUNCTION" => function(){} ));
or
$dbh = new PDO("mysql:host=$HOST;port=$HOST_PORT;dbname=$DB", $USER, $PASSWORD, array(
"MYSQL_DIALOG_AUTH_CALLBACK_FUNCTION" => "an_callback_function" ));
function an_callback_function($db,$type,$message){
  return true; /* wait other message */
  return false; /* disconnect */
  $db->mysqli_auth_dialog_send($db,"message");
}


Actual result:
--------------
no client side auth dialog interface


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=68281&edit=1


Thread (7 messages)

« previous php.bugs (#188250) next »