php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68281 mariadb server with dialog auth method
Submitted: 2014-10-22 05:58 UTC Modified: 2016-11-23 13:39 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: roberto at spadim dot com dot br Assigned: cmb (profile)
Status: Closed Package: MySQL related
PHP Version: Irrelevant OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
35 - 5 = ?
Subscribe to this entry?

 
 [2014-10-22 05:58 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-22 06:08 UTC] 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 06:12 UTC] 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:13 UTC] roberto at spadim dot com dot br
what kinds of questions exists:

https://github.com/MariaDB/server/blob/e974b564389af8251c2ba51060e6129e45431586/include/mysql/auth_dialog_client.h
 [2014-10-22 06:23 UTC] roberto at spadim dot com dot br
Reading examples from mariadb client/server auth dialog plugin

at php side, we must include a function as callback to builtin_ask function: 
MYSQL_PLUGIN_EXPORT char *mysql_authentication_dialog_ask(MYSQL *mysql, int type,const char *prompt,char *buf, int buf_len)

and the return of this function is the 'mysql_auth_dialog_send'

in other words at php side we have:

mysql_set_callback('any_function');
mysql_connect();

if we got dialog, any_function will be called, the problem is... at what connect we are? maybe "struct st_mysql *mysql" solve this problem, if not at least we can call a function and php user must know what he is doing


at mysqli and pdo we could pass this callback function name as a mysqli_option or a array parameter (pdo)

well i think that's all for now (04:22AM i didn't sleep yet, good night)
 [2014-10-22 06:33 UTC] roberto at spadim dot com dot br
From heidisql:
https://code.google.com/p/heidisql/source/browse/trunk/source/dbconnection.pas#671

one point... when using dialog, we can't use persistent connection, since each new connection create a new dialog...
 [2016-11-23 13:39 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2016-11-23 13:39 UTC] cmb@php.net
The MySSQL extension (ext/mysql) has been deprecated as of PHP
5.5.0 and removed as of PHP 7.0.0, so we won't implement any
feature requests anymore.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC