23#ifndef SQL_AUTHENTICATION_INCLUDED
24#define SQL_AUTHENTICATION_INCLUDED
26#include <openssl/rsa.h>
105#if OPENSSL_VERSION_NUMBER >= 0x30000000L
119#if OPENSSL_VERSION_NUMBER >= 0x30000000L
121 char **key_text_buffer);
123 bool read_key_file(
RSA **key_ptr,
bool is_priv_key,
char **key_text_buffer);
139#if OPENSSL_VERSION_NUMBER >= 0x30000000L
248#define AUTH_DEFAULT_RSA_PRIVATE_KEY "private_key.pem"
249#define AUTH_DEFAULT_RSA_PUBLIC_KEY "public_key.pem"
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:250
Definition: sql_auth_cache.h:245
Definition: sql_authentication.h:168
bool m_valid
Definition: sql_authentication.h:240
Cached_authentication_plugins()
Cached_authentication_plugins constructor.
Definition: sql_authentication.cc:1361
static const LEX_CSTRING cached_plugins_names[(uint) PLUGIN_LAST]
Definition: sql_authentication.h:170
static bool compare_plugin(cached_plugins_enum plugin_index, LEX_CSTRING plugin)
Compare given plugin against one of the cached ones.
Definition: sql_authentication.h:183
bool is_valid()
Definition: sql_authentication.h:237
static const char * get_plugin_name(cached_plugins_enum plugin_index)
Get name of the plugin at given index.
Definition: sql_authentication.h:213
plugin_ref cached_plugins[(uint) PLUGIN_LAST]
Definition: sql_authentication.h:236
plugin_ref get_cached_plugin_ref(cached_plugins_enum plugin_index)
Fetch cached plugin handle.
Definition: sql_authentication.h:231
plugin_ref get_cached_plugin_ref(const LEX_CSTRING *plugin)
Get plugin_ref if plugin is cached.
Definition: sql_authentication.cc:1395
static bool auth_plugin_is_built_in(LEX_CSTRING *plugin)
Check if given plugin is a builtin.
Definition: sql_authentication.h:199
static void optimize_plugin_compare_by_pointer(LEX_CSTRING *plugin)
Use known pointers for cached plugins to improve comparison time.
Definition: sql_authentication.cc:1343
~Cached_authentication_plugins()
Cached_authentication_plugins destructor.
Definition: sql_authentication.cc:1381
Definition: protocol_classic.h:53
Container of all restrictions for a given user.
Definition: partial_revokes.h:117
Definition: sql_authentication.h:103
bool read_key_file(RSA **key_ptr, bool is_priv_key, char **key_text_buffer)
Read a key file and store its value in RSA structure.
Definition: sql_authentication.cc:1530
void * allocate_pem_buffer(size_t buffer_len)
Definition: sql_authentication.cc:1618
char ** m_public_key_path
Definition: sql_authentication.h:115
RSA * get_public_key()
Definition: sql_authentication.h:144
void get_key_file_path(char *key, String *key_file_path)
Set key file path.
Definition: sql_authentication.cc:1490
int get_cipher_length()
Definition: sql_authentication.cc:1623
int m_cipher_len
Definition: sql_authentication.h:112
RSA * m_private_key
Definition: sql_authentication.h:110
RSA * get_private_key()
Definition: sql_authentication.h:143
~Rsa_authentication_keys()=default
bool read_rsa_keys()
Read RSA private key and public key from file and store them in m_private_key and m_public_key.
Definition: sql_authentication.cc:1640
char ** m_private_key_path
Definition: sql_authentication.h:114
char * m_pem_public_key
Definition: sql_authentication.h:113
const char * get_public_key_as_pem(void)
Definition: sql_authentication.h:149
RSA * m_public_key
Definition: sql_authentication.h:109
Rsa_authentication_keys(char **private_key_path, char **public_key_path)
Definition: sql_authentication.h:127
void free_memory()
Definition: sql_authentication.cc:1598
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
Definition: sql_authentication.h:46
Thd_charset_adapter(THD *thd_arg)
Definition: sql_authentication.h:50
const CHARSET_INFO * charset()
Definition: sql_authentication.cc:1480
bool init_client_charset(uint cs_number)
Definition: sql_authentication.cc:1474
THD * thd
Definition: sql_authentication.h:47
A better implementation of the UNIX ctype(3) library.
uint32 my_thread_id
Definition: my_thread_local.h:33
Authentication Plugin API.
This file defines constants and data structures that are the same for both client- and server-side au...
required string key
Definition: replication_asynchronous_connection_failover.proto:59
int show_rsa_public_key(THD *thd, SHOW_VAR *var, char *buff)
Definition: sql_authentication.cc:4672
ACL_USER * decoy_user(const LEX_CSTRING &username, const LEX_CSTRING &hostname, MEM_ROOT *mem, struct rand_struct *rand, bool is_initialized)
When authentication is attempted using an unknown username a dummy user account with no authenticatio...
Definition: sql_authentication.cc:2393
cached_plugins_enum
Definition: sql_authentication.h:158
@ PLUGIN_LAST
Definition: sql_authentication.h:163
@ PLUGIN_CACHING_SHA2_PASSWORD
Definition: sql_authentication.h:159
@ PLUGIN_SHA256_PASSWORD
Definition: sql_authentication.h:161
@ PLUGIN_MYSQL_NATIVE_PASSWORD
Definition: sql_authentication.h:160
bool allow_all_hosts
Definition: sql_auth_cache.cc:163
Cached_authentication_plugins * g_cached_authentication_plugins
Definition: sql_authentication.cc:1446
void deinit_rsa_keys(void)
Definition: sql_authentication.cc:4678
LEX_CSTRING default_auth_plugin_name
Definition: sql_authentication.cc:1331
struct rsa_st RSA
Definition: sql_authentication.h:102
bool init_rsa_keys(void)
Loads the RSA key pair from disk and store them in a global variable.
Definition: sql_authentication.cc:4712
LEX_CSTRING validate_password_plugin_name
Definition: sql_authentication.cc:1328
static MEM_ROOT mem
Definition: sql_servers.cc:99
Definition: m_ctype.h:422
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
The internal version of what plugins know as MYSQL_PLUGIN_VIO, basically the context of the authentic...
Definition: sql_authentication.h:60
ulong max_client_packet_length
Definition: sql_authentication.h:87
uint pkt_len
Definition: sql_authentication.h:69
@ FAILURE
Definition: sql_authentication.h:78
@ START_MFA
Definition: sql_authentication.h:78
@ SUCCESS
Definition: sql_authentication.h:78
@ RESTART
Definition: sql_authentication.h:78
char * pkt
Definition: sql_authentication.h:73
const ACL_USER * acl_user
Definition: sql_authentication.h:62
struct MPVIO_EXT::@39 cached_server_packet
this caches the first plugin packet for restart request on the client
int vio_is_encrypted
Definition: sql_authentication.h:92
enum MPVIO_EXT::@40 status
when plugin returns a failure this tells us what really happened
const char * ip
Definition: sql_authentication.h:88
int packets_written
counters for send/received packets
Definition: sql_authentication.h:76
Protocol_classic * protocol
Definition: sql_authentication.h:86
int packets_read
Definition: sql_authentication.h:76
LEX_STRING db
db name from the handshake packet
Definition: sql_authentication.h:65
LEX_CSTRING acl_user_plugin
Definition: sql_authentication.h:91
my_thread_id thread_id
Definition: sql_authentication.h:84
const char * pkt
pointers into NET::buff
Definition: sql_authentication.h:68
bool can_authenticate()
Definition: sql_authentication.cc:6079
struct rand_struct * rand
Definition: sql_authentication.h:83
plugin_ref plugin
what plugin we're under
Definition: sql_authentication.h:64
const char * host
Definition: sql_authentication.h:89
char * scramble
Definition: sql_authentication.h:81
struct MPVIO_EXT::@38 cached_client_reply
when restarting a plugin this caches the last client reply
uint * server_status
Definition: sql_authentication.h:85
MYSQL_SERVER_AUTH_INFO auth_info
Definition: sql_authentication.h:61
Thd_charset_adapter * charset_adapter
Definition: sql_authentication.h:90
Restrictions * restrictions
Definition: sql_authentication.h:63
MEM_ROOT * mem_root
Definition: sql_authentication.h:82
Definition: mysql_lex_string.h:39
const char * str
Definition: mysql_lex_string.h:40
Definition: mysql_lex_string.h:34
Provides plugin access to communication channel.
Definition: plugin_auth_common.h:145
Provides server plugin access to authentication information.
Definition: plugin_auth.h:70
SHOW STATUS Server status variable.
Definition: status_var.h:78
Definition: mysql_com.h:1112
Definition: sql_plugin_ref.h:44
std::atomic< bool > is_initialized(false)