• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..10-Feb-2022-

cmake/H10-Feb-2022-10384

mysql-test/auth_gssapi/H10-Feb-2022-197172

README.mdH A D10-Feb-20225.2 KiB13084

client_plugin.ccH A D10-Feb-20223.2 KiB11362

common.hH A D10-Feb-2022138 52

gssapi_client.ccH A D10-Feb-20224 KiB12882

gssapi_errmsg.ccH A D10-Feb-20222.4 KiB8146

gssapi_errmsg.hH A D10-Feb-20221.4 KiB301

gssapi_server.ccH A D10-Feb-20226.9 KiB271215

server_plugin.ccH A D10-Feb-20224.8 KiB166105

server_plugin.hH A D10-Feb-20221.9 KiB5214

sspi.hH A D10-Feb-20221.6 KiB389

sspi_client.ccH A D10-Feb-20224.7 KiB184130

sspi_errmsg.ccH A D10-Feb-20224.8 KiB151116

sspi_server.ccH A D10-Feb-20228.3 KiB331251

README.md

1# GSSAPI/SSPI authentication for MariaDB
2
3This article gives instructions on configuring GSSAPI authentication plugin
4for MariaDB for passwordless login.
5
6On Unix systems, GSSAPI is usually synonymous with Kerberos authentication.
7Windows has slightly different but very similar API called SSPI,  that along with Kerberos, also supports NTLM authentication.
8
9This plugin includes support for Kerberos on Unix, but also can be used as for Windows authentication with or without domain
10environment.
11
12## Server-side preparations on Unix
13To use the plugin, some preparation need to be done on the server side on Unixes.
14MariaDB server will need read access to the Kerberos keytab file, that contains  service principal name for the MariaDB server.
15
16
17If you are using **Unix Kerberos KDC (MIT,Heimdal)**
18
19-	Create service principal using kadmin tool
20
21```
22kadmin -q "addprinc -randkey mariadb/host.domain.com"
23```
24
25(replace host.domain.com with fully qualified DNS name for the server host)
26
27-	Export the newly created user to the keytab file
28
29```
30kadmin -q "ktadd -k /path/to/mariadb.keytab mariadb/host.domain.com"
31```
32
33More details can be found [here](http://www.microhowto.info/howto/create_a_service_principal_using_mit_kerberos.html)
34and [here](http://www.microhowto.info/howto/add_a_host_or_service_principal_to_a_keytab_using_mit_kerberos.html)
35
36If you are using **Windows Active Directory KDC**
37you can need to create keytab using ktpass.exe tool on Windows,  map principal user to an existing domain user like this
38
39```
40ktpass.exe /princ mariadb/host.domain.com@DOMAIN.COM /mapuser someuser /pass MyPas$w0rd /out mariadb.keytab /crypto all /ptype KRB5_NT_PRINCIPAL /mapop set
41```
42
43and then transfer the keytab file to the Unix server. See [Microsoft documentation](https://technet.microsoft.com/en-us/library/cc753771.aspx) for details.
44
45
46## Server side preparations on Windows.
47Usually nothing need to be done.  MariaDB server should to run on a domain joined machine, either as NetworkService account
48(which is default if it runs as service) or run under any other domain account credentials.
49Creating service principal is not required here (but you can still do it using [_setspn_](https://technet.microsoft.com/en-us/library/cc731241.aspx) tool)
50
51
52# Installing plugin
53-	Start the server
54
55-	On Unix, edit my the my.cnf/my.ini configuration file, set the parameter gssapi-keytab-path to point to previously
56created keytab path.
57
58```
59	gssapi-keytab-path=/path/to/mariadb.keytab
60```
61
62-	Optionally on Unix, in case the service principal name differs from default mariadb/host.domain.com@REALM,
63configure alternative principal name with
64
65```
66    gssapi-principal-name=alternative/principalname@REALM
67```
68
69-	In mysql command line client, execute
70
71```
72	INSTALL SONAME 'auth_gssapi'
73```
74
75#Creating users
76
77Now, you can create a user for GSSAPI/SSPI authentication. CREATE USER command, for Kerberos user
78would be like this (*long* form, see below for short one)
79
80```
81CREATE USER usr1 IDENTIFIED WITH gssapi AS 'usr1@EXAMPLE.COM';
82```
83
84(replace  with real username and realm)
85
86The part after AS is mechanism specific, and needs to be ``machine\\usr1`` for Windows users identified with NTLM.
87
88You may also use alternative *short* form of CREATE USER
89
90```
91CREATE USER usr1 IDENTIFIED WITH gssapi;
92```
93
94If this syntax is used, realm part is *not* used for comparison
95thus 'usr1@EXAMPLE.COM', 'usr1@EXAMPLE.CO.UK' and 'mymachine\usr1' will all identify as 'usr1'.
96
97#Login as GSSAPI user with command line clients
98
99Using command line client, do
100
101```
102mysql --plugin-dir=/path/to/plugin-dir -u usr1
103```
104
105#Plugin variables
106-	**gssapi-keytab-path** (Unix only) - Path to the server keytab file
107-	**gssapi-principal-name** - name of the service principal.
108-	**gssapi-mech-name** (Windows only) - Name of the SSPI package used by server. Can be either 'Kerberos' or 'Negotiate'.
109 Defaults to 'Negotiate' (both Kerberos and NTLM users can connect)
110 Set it to 'Kerberos', to prevent less secure NTLM in domain environments,  but leave it as default(Negotiate)
111 to allow non-domain environment (e.g if server does not run in domain environment).
112
113
114#Implementation
115
116Overview of the protocol between client and server
117
1181. Server : Construct gssapi-principal-name if not set in my.cnf. On Unixes defaults to hostbased name for service "mariadb". On Windows to user's or machine's domain names.
119Acquire credentials for gssapi-principal-name with ```gss_acquire_cred() / AcquireSecurityCredentials()```.
120Send packet with principal name and mech ```"gssapi-principal-name\0gssapi-mech-name\0"``` to client ( on Unix, empty string used for gssapi-mech)
121
1222. Client: execute ```gss_init_sec_context() / InitializeSecurityContext()``` passing gssapi-principal-name / gssapi-mech-name parameters.
123Send resulting GSSAPI blob to server.
124
1253. Server : receive blob from client, execute ```gss_accept_sec_context()/ AcceptSecurityContext()```, send resulting blob back to client
126
1274. Perform  2. and 3. can until both client and server decide that authentication is done, or until some error occurred. If authentication was successful, GSSAPI context (an opaque structure) is generated on both client and server sides.
128
1295. Server : Client name is extracted from the context, and compared to the name provided by client(with or without realm). If name matches, plugin returns success.
130