Skip to content

Commit 84e84ed

Browse files
committed
More doxygen on the protocol auth methods
1 parent ea3fd43 commit 84e84ed

File tree

6 files changed

+117
-12
lines changed

6 files changed

+117
-12
lines changed

Doxyfile

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0,
@@ -478,7 +478,7 @@ TYPEDEF_HIDES_STRUCT = NO
478478
# the optimal cache size from a speed point of view.
479479
# Minimum value: 0, maximum value: 9, default value: 0.
480480

481-
LOOKUP_CACHE_SIZE = 1
481+
LOOKUP_CACHE_SIZE = 2
482482

483483
#---------------------------------------------------------------------------
484484
# Build related configuration options
@@ -884,6 +884,7 @@ INPUT = ./client \
884884
./sql-common \
885885
./storage \
886886
./strings \
887+
./libmysql \
887888
./vio
888889

889890
# This tag can be used to specify the character encoding of the source files
@@ -948,8 +949,6 @@ EXCLUDE = cmd-line-utils \
948949
include/sql_state.h \
949950
internal \
950951
libevent \
951-
libmysql \
952-
libmysql_r \
953952
plugin/innodb_memcached/daemon_memcached/include/memcached \
954953
source_downloads \
955954
sql/sql_hints.cc \

libmysql/authentication_win/handshake.cc

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -85,15 +85,13 @@ Handshake::~Handshake()
8585
/**
8686
Read and process data packets from the other end of a connection.
8787
88-
@param[IN] con a connection to read packets from
89-
9088
Packets are read and processed until authentication handshake is
9189
complete. It is assumed that the peer will send at least one packet.
9290
Packets are processed with @c process_data() method. If new data is
9391
generated during packet processing, this data is sent to the peer and
9492
another round of packet exchange starts.
9593
96-
@return 0 on success.
94+
@retval 0 on success.
9795
9896
@note In case of error, appropriate error message is logged.
9997
*/

libmysql/authentication_win/handshake.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -162,7 +162,7 @@ class Handshake
162162
This method is used inside @c packet_processing_loop to process
163163
data packets received from the other end.
164164
165-
@param[IN] data data to be processed
165+
@param data data to be processed
166166
167167
@return A blob with data to be sent to the other end or null blob if
168168
no more data needs to be exchanged.

libmysql/authentication_win/handshake_client.cc

+62-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -62,6 +62,7 @@ class Handshake_client: public Handshake
6262
@param con connection for communication with the peer
6363
@param target name of the target service with which we will authenticate
6464
(can be NULL if not used)
65+
@param len length of target
6566
6667
Some security packages (like Kerberos) require providing explicit name
6768
of the service with which a client wants to authenticate. The server-side
@@ -315,6 +316,66 @@ Blob Handshake_client::process_data(const Blob &data)
315316

316317
/**********************************************************************/
317318

319+
/**
320+
@page page_protocol_connection_phase_authentication_methods_authentication_windows Windows Native Authentication
321+
322+
Authentication::WindowsAuth:
323+
324+
<ul>
325+
<li>
326+
The server name is *authentication_windows*
327+
</li>
328+
<li>
329+
The client name is *authentication_windows_client*
330+
</li>
331+
</ul>
332+
333+
The Windows Native Authentication method is more complex than the other
334+
methods and extends the auth protocol as it has to send more data forth
335+
and back than the old handshake permitted.
336+
337+
Basically it wraps the output of the
338+
[Negotiate SSP]("http://msdn.microsoft.com/en-us/library/windows/desktop/aa378748(v=VS.85).aspx")
339+
in the Auth Phase protocol which either means
340+
@ref sect_protocol_connection_phase_authentication_methods_authentication_windows_ntlm or
341+
@ref sect_protocol_connection_phase_authentication_methods_authentication_windows_spnego
342+
are used as underlying protocol.
343+
344+
Due to the implementation details the Windows Native Authentication method
345+
doesn't use the fast path of the @ref page_protocol_connection_phase, but is
346+
only triggered on request as part of the
347+
@ref page_protocol_connection_phase_packets_protocol_auth_switch_request packet.
348+
349+
350+
@note Due to implementation details (again) the first packet sent from the
351+
client to the server is expected to be either
352+
<ul><li>254 bytes long max or</li>
353+
<li>send the first 254 bytes first, appended by 1 byte with a magic value
354+
plus a 2nd packet with rest of the data</li></ul>
355+
Also following windows authentication packets don't get split.
356+
357+
The client will send either a
358+
@ref sect_protocol_connection_phase_authentication_methods_authentication_windows_spnego
359+
or a @ref sect_protocol_connection_phase_authentication_methods_authentication_windows_ntlm
360+
packet as a next packet.
361+
362+
To implement the protocol one can use several existing implementations:
363+
<ul>
364+
<li>MS Windows provides
365+
[InitializeSecurityContextW]("http://msdn.microsoft.com/en-us/library/windows/desktop/aa375509(v=VS.85).aspx")
366+
and [AcceptSecurityContext]("http://msdn.microsoft.com/en-us/library/aa374703.aspx")
367+
</li>
368+
<li>A open source implemenation of NTML, SPNEGO and Kerberos5 are provided by
369+
[Heimdal]("http://www.h5l.org/")
370+
</li>
371+
<li>Java6 added SPNEGO support to
372+
[JGSS]("http://download.oracle.com/javase/6/docs/technotes/guides/security/jgss/lab/part5.html#SPNEGO")
373+
which also provides the NTLM and Kerberos5 support.
374+
</li></ul>
375+
376+
@section sect_protocol_connection_phase_authentication_methods_authentication_windows_spnego SPNEGO
377+
@section sect_protocol_connection_phase_authentication_methods_authentication_windows_ntlm NTLM
378+
*/
318379

319380
/**
320381
Perform authentication handshake from client side.

sql-common/client.cc

+45
Original file line numberDiff line numberDiff line change
@@ -6794,6 +6794,51 @@ static int native_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
67946794
DBUG_RETURN(CR_OK);
67956795
}
67966796

6797+
/**
6798+
@page page_protocol_connection_phase_authentication_methods_clear_text_password Clear text client plugin
6799+
6800+
<ul>
6801+
<li>
6802+
This client side plugin is used by a number of server plugins:
6803+
LDAP (*authentication_ldap_simple*) and PAM (*authentication_pam*) to name a few.
6804+
</li>
6805+
<li>
6806+
The client name is *mysql_clear_password*
6807+
</li>
6808+
<li>
6809+
Client side requires nothing from the server. But the server generates
6810+
and sends a 20-byte
6811+
@ref page_protocol_connection_phase_authentication_methods_native_password_authentication
6812+
compatible scramble.
6813+
</li>
6814+
<li>
6815+
Client side sends the password in clear text to the server
6816+
</li>
6817+
</ul>
6818+
6819+
@startuml
6820+
Server->Client: 20 bytes of scramble to be ignored
6821+
Client->Server: The clear text password. null terminated.
6822+
@enduml
6823+
6824+
@note
6825+
Sending the scramble is not necessary for the clear text
6826+
method, but, since the server always initiates the exchange by
6827+
sending @ref page_protocol_connection_phase_packets_protocol_handshake
6828+
and that one has a placeholder for authentication plugin dependent data the
6829+
server does fill that space with a scramble should it come to pass that
6830+
it will back down to
6831+
@ref page_protocol_connection_phase_authentication_methods_native_password_authentication.
6832+
This is also why it's OK no to specifically read this in
6833+
@ref clear_password_auth_client since it's already read as a part of
6834+
the initial exchange.
6835+
6836+
6837+
@sa ::clear_password_auth_client, ::server_mpvio_write_packet,
6838+
::send_server_handshake_packet
6839+
*/
6840+
6841+
67976842
/**
67986843
The main function of the mysql_clear_password authentication plugin.
67996844
*/

sql/auth/sql_authentication.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@
598598
The server name is *mysql_old_password*
599599
</li>
600600
<li>
601-
The client name is *mysql_old_password"
601+
The client name is *mysql_old_password*
602602
</li>
603603
<li>
604604
Client side requires an 8-byte random challenge from server
@@ -624,6 +624,8 @@
624624
625625
@subpage page_protocol_connection_phase_authentication_methods_native_password_authentication
626626
@subpage page_caching_sha2_authentication_exchanges
627+
@subpage page_protocol_connection_phase_authentication_methods_clear_text_password
628+
@subpage page_protocol_connection_phase_authentication_methods_authentication_windows
627629
*/
628630

629631
/**

0 commit comments

Comments
 (0)