Configuring SingleStore for Kerberos Authentication
On this page
Once you have generated an SPN and a keytab file on the Kerberos KDC server, you can configure SingleStore to allow access for Kerberos-authenticated users.
Depending on your SingleStore cluster configuration, the SPN and keytab file may need to be configured on one or many aggregator nodes.
The following steps describe how to use the SPN and keytab file created earlier.
Copying the Keytab File to SingleStore
A keytab file is a credential that can be used to access network resources, so it is important to consider the security implications of copying it from one location to another.
Use a secure file transfer method, such as scp
, to copy the keytab file from the KDC server to each SingleStore aggregator node.memsql.
file in the next step.
Configuring memsql. cnf
Before Kerberos-authenticated users can connect to SingleStore, you must configure each SingleStore aggregator node’s memsql.
file with two variables:
-
gssapi-keytab-path
: The local path to the keytab file that was created on the KDC server and copied to the node.For example: /path/to/memsql.
keytab -
gssapi-principal-name
: The SPN for SingleStore that was created on the KDC server.For example: memsql/host.
domain. com@DOMAIN. COM
Note
You cannot use the SET GLOBAL VARIABLE
command when setting these variables.memsql.
file on the applicable node using the steps described below.
To set these variables in the memsql.
file:
-
Ensure that the cluster is stopped before continuing.
-
Open the aggregator node’s
memsql.
file in a text editor (typical location for this file).cnf -
Add the following line to the file anywhere below the
[server]
declaration:[server] ... gssapi-keytab-path = /path/to/memsql.keytab gssapi-principal-name = memsql/host.domain.com@DOMAIN.COM ...
-
Save the file.
-
Repeat this process for each aggregator node’s
memsql.
file.cnf -
After the
memsql.
file has been updated for each aggregator node in the cluster, start the cluster.cnf -
Verify that the change was successful by executing the following command on one of the affected nodes:
SHOW GLOBAL VARIABLES LIKE 'gssapi%';+-----------------------+-------------------------------------+ | Variable_name | Value | +-----------------------+-------------------------------------+ | gssapi_keytab_path | /path/to/memsql.keytab | | gssapi_principal_name | memsql/host.domain.com@DOMAIN.COM | +-----------------------+-------------------------------------+ 2 rows in set (0.00 sec)
Granting a User Kerberos Authentication Permissions
Now that the SingleStore cluster has been configured, you can use the GRANT command to create a Kerberos-authenticated user and grant permissions.
Mapping a Single Kerberos Identity
The following example creates a new SingleStore user ('user1'@'%'
) authenticating via Kerberos on all databases, where the Kerberos SPN is user1@EXAMPLE.
:
GRANT ALL ON *.* TO 'user1'@'%' IDENTIFIED WITH 'authentication_gss' AS 'user1@EXAMPLE.COM';
When this command is run, the 'user1'@'%'
SingleStore user is created and mapped to the user1@EXAMPLE.
Kerberos SPN.'user1'@'%'
will require a Ticket Granting Ticket (TGT) from the KDC server for the user1@EXAMPLE.
SPN.
Note
The recommended way to create users is through the CREATE USER
command.IDENTIFIED WITH
clause.
GRANT DELETE ON db.* TO steve;
Mapping with Regular Expressions
You may also use regular expressions in the AS
clause of the GRANT
statement.
Caution
When using a regular expression in a GRANT
statement, confirm that the expression evaluates in an expected manner.
Regular expressions can only be used in the AS
clause of the GRANT
statement.AS
clause.
To enable regular expressions support, the first character in your AS
clause must start with a forward slash (/
).^
(start of line) and $
(end of line) operators to indicate when the regular expression should start and end.
Consider the following example that creates a new user:
GRANT ALL ON *.* to 'user1'@'%' IDENTIFIED WITH 'authentication_gss' AS '/^user1@EXAMPLE\.COM$';
This example creates the user via regular expression to match the user1@EXAMPLE.
string in any Kerberos SPN that attempts to authenticate with SingleStore.user1@EXAMPLE.
SPN will be matched.
GRANT ALL ON *.* to 'user1'@'%' IDENTIFIED WITH 'authentication_gss' AS '/user1@EXAMPLE\.COM$';
The example above differs from the previous example by omitting the ^
start of line operator.user1@EXAMPLE.
, such as other_
.
Always ensure that your regular expression produces the intended result.
Example: Optional Subdomain
The following example creates the SingleStore user 'user1'@'%'
with a Kerberos SPN that contains an optional subdomain.
GRANT ALL ON *.* to 'user1'@'%' IDENTIFIED WITH 'authentication_gss' AS '/^user1@(SUBDOMAIN\.)?EXAMPLE\.COM$';
Example: Optional Domain Suffix
The following example creates the SingleStore user 'user1'@'%'
with a Kerberos SPN across domains with different suffixes, namely .
, .
, or .
.
GRANT ALL ON *.* to 'user1'@'%' IDENTIFIED WITH 'authentication_gss' AS '/^user1@EXAMPLE\.(COM|NET|ORG)$';
Connecting to SingleStore as a Kerberos-authenticated User
After a SingleStore user has been associated with a Kerberos SPN, you can connect to SingleStore as that user.kinit
from the terminal.
Use the SingleStore Client
Install the SingleStore client via the following instructions.
Once the SingleStore client has been installed:
-
Obtain a ticket from the Kerberos server.
kinit <username>@<hostname>Password for <username>@<hostname>:
-
Connect with the SingleStore client.
-
For a package-based installation of the SingleStore client.
singlestore -h<hostname> --plugin-dir=/usr/lib/singlestore-client/plugin/ -u<username> -
For a tarball-based installation of the SingleStore client.
singlestore -h<hostname> --plugin-dir=/path/to/singlestore-client/plugin/ -u<username>
-
Note that this authentication method requires you to specify the plugin directory that contains the auth_
plugin for the SingleStore ODBC Driver, as described in Assumptions and Prerequisites.
To connect using ODBC, consider the following example:
Driver=<path-to-singlestore-odbc-connector>;Database=information_schema;ServerName=10.0.0.1;Port=3306;UID=myusername;Plugin_Dir=<path-to-gssapi-plugin-directory>;
Last modified: October 4, 2024