24#ifndef SQL_AUTHENTICATION_INCLUDED
25#define SQL_AUTHENTICATION_INCLUDED
27#include <openssl/rsa.h>
106#if OPENSSL_VERSION_NUMBER >= 0x30000000L
120#if OPENSSL_VERSION_NUMBER >= 0x30000000L
122 char **key_text_buffer);
124 bool read_key_file(
RSA **key_ptr,
bool is_priv_key,
char **key_text_buffer);
140#if OPENSSL_VERSION_NUMBER >= 0x30000000L
249#define AUTH_DEFAULT_RSA_PRIVATE_KEY "private_key.pem"
250#define AUTH_DEFAULT_RSA_PUBLIC_KEY "public_key.pem"
Definition: sql_auth_cache.h:247
Definition: sql_authentication.h:169
bool m_valid
Definition: sql_authentication.h:241
Cached_authentication_plugins()
Cached_authentication_plugins constructor.
Definition: sql_authentication.cc:1034
static const LEX_CSTRING cached_plugins_names[(uint) PLUGIN_LAST]
Definition: sql_authentication.h:171
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:184
bool is_valid()
Definition: sql_authentication.h:238
static const char * get_plugin_name(cached_plugins_enum plugin_index)
Get name of the plugin at given index.
Definition: sql_authentication.h:214
plugin_ref cached_plugins[(uint) PLUGIN_LAST]
Definition: sql_authentication.h:237
plugin_ref get_cached_plugin_ref(cached_plugins_enum plugin_index)
Fetch cached plugin handle.
Definition: sql_authentication.h:232
plugin_ref get_cached_plugin_ref(const LEX_CSTRING *plugin)
Get plugin_ref if plugin is cached.
Definition: sql_authentication.cc:1066
static bool auth_plugin_is_built_in(LEX_CSTRING *plugin)
Check if given plugin is a builtin.
Definition: sql_authentication.h:200
static void optimize_plugin_compare_by_pointer(LEX_CSTRING *plugin)
Use known pointers for cached plugins to improve comparison time.
Definition: sql_authentication.cc:1016
~Cached_authentication_plugins()
Cached_authentication_plugins destructor.
Definition: sql_authentication.cc:1052
Definition: protocol_classic.h:52
Container of all restrictions for a given user.
Definition: partial_revokes.h:155
Definition: sql_authentication.h:104
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:1201
void * allocate_pem_buffer(size_t buffer_len)
Definition: sql_authentication.cc:1289
char ** m_public_key_path
Definition: sql_authentication.h:116
RSA * get_public_key()
Definition: sql_authentication.h:145
void get_key_file_path(char *key, String *key_file_path)
Set key file path.
Definition: sql_authentication.cc:1161
int get_cipher_length()
Definition: sql_authentication.cc:1294
int m_cipher_len
Definition: sql_authentication.h:113
RSA * m_private_key
Definition: sql_authentication.h:111
RSA * get_private_key()
Definition: sql_authentication.h:144
~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:1311
char ** m_private_key_path
Definition: sql_authentication.h:115
char * m_pem_public_key
Definition: sql_authentication.h:114
const char * get_public_key_as_pem(void)
Definition: sql_authentication.h:150
RSA * m_public_key
Definition: sql_authentication.h:110
Rsa_authentication_keys(char **private_key_path, char **public_key_path)
Definition: sql_authentication.h:128
void free_memory()
Definition: sql_authentication.cc:1269
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:168
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Definition: sql_authentication.h:47
Thd_charset_adapter(THD *thd_arg)
Definition: sql_authentication.h:51
const CHARSET_INFO * charset()
Definition: sql_authentication.cc:1151
bool init_client_charset(uint cs_number)
Definition: sql_authentication.cc:1145
THD * thd
Definition: sql_authentication.h:48
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
A better implementation of the UNIX ctype(3) library.
uint32 my_thread_id
Definition: my_thread_local.h:34
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:60
int show_rsa_public_key(THD *thd, SHOW_VAR *var, char *buff)
Definition: sql_authentication.cc:4620
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:2064
cached_plugins_enum
Definition: sql_authentication.h:159
@ PLUGIN_LAST
Definition: sql_authentication.h:164
@ PLUGIN_CACHING_SHA2_PASSWORD
Definition: sql_authentication.h:160
@ PLUGIN_SHA256_PASSWORD
Definition: sql_authentication.h:162
@ PLUGIN_MYSQL_NATIVE_PASSWORD
Definition: sql_authentication.h:161
bool allow_all_hosts
Definition: sql_auth_cache.cc:162
Cached_authentication_plugins * g_cached_authentication_plugins
Definition: sql_authentication.cc:1117
void deinit_rsa_keys(void)
Definition: sql_authentication.cc:4626
LEX_CSTRING default_auth_plugin_name
Definition: sql_authentication.cc:1004
struct rsa_st RSA
Definition: sql_authentication.h:103
bool init_rsa_keys(void)
Loads the RSA key pair from disk and store them in a global variable.
Definition: sql_authentication.cc:4660
LEX_CSTRING validate_password_plugin_name
Definition: sql_authentication.cc:1001
static MEM_ROOT mem
Definition: sql_servers.cc:99
Definition: m_ctype.h:385
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
The internal version of what plugins know as MYSQL_PLUGIN_VIO, basically the context of the authentic...
Definition: sql_authentication.h:61
ulong max_client_packet_length
Definition: sql_authentication.h:88
uint pkt_len
Definition: sql_authentication.h:70
char * pkt
Definition: sql_authentication.h:74
const ACL_USER * acl_user
Definition: sql_authentication.h:63
struct MPVIO_EXT::@37 cached_server_packet
this caches the first plugin packet for restart request on the client
int vio_is_encrypted
Definition: sql_authentication.h:93
const char * ip
Definition: sql_authentication.h:89
int packets_written
counters for send/received packets
Definition: sql_authentication.h:77
Protocol_classic * protocol
Definition: sql_authentication.h:87
int packets_read
Definition: sql_authentication.h:77
struct MPVIO_EXT::@36 cached_client_reply
when restarting a plugin this caches the last client reply
LEX_STRING db
db name from the handshake packet
Definition: sql_authentication.h:66
LEX_CSTRING acl_user_plugin
Definition: sql_authentication.h:92
my_thread_id thread_id
Definition: sql_authentication.h:85
const char * pkt
pointers into NET::buff
Definition: sql_authentication.h:69
bool can_authenticate()
Definition: sql_authentication.cc:6031
struct rand_struct * rand
Definition: sql_authentication.h:84
plugin_ref plugin
what plugin we're under
Definition: sql_authentication.h:65
const char * host
Definition: sql_authentication.h:90
char * scramble
Definition: sql_authentication.h:82
uint * server_status
Definition: sql_authentication.h:86
@ FAILURE
Definition: sql_authentication.h:79
@ START_MFA
Definition: sql_authentication.h:79
@ SUCCESS
Definition: sql_authentication.h:79
@ RESTART
Definition: sql_authentication.h:79
MYSQL_SERVER_AUTH_INFO auth_info
Definition: sql_authentication.h:62
Thd_charset_adapter * charset_adapter
Definition: sql_authentication.h:91
Restrictions * restrictions
Definition: sql_authentication.h:64
enum MPVIO_EXT::@38 status
when plugin returns a failure this tells us what really happened
MEM_ROOT * mem_root
Definition: sql_authentication.h:83
Definition: mysql_lex_string.h:40
const char * str
Definition: mysql_lex_string.h:41
Definition: mysql_lex_string.h:35
Provides plugin access to communication channel.
Definition: plugin_auth_common.h:146
Provides server plugin access to authentication information.
Definition: plugin_auth.h:71
SHOW STATUS Server status variable.
Definition: status_var.h:79
Definition: mysql_com.h:1108
Definition: sql_plugin_ref.h:45
unsigned int uint
Definition: uca9-dump.cc:75
std::atomic< bool > is_initialized(false)