MySQL  8.0.19
Source Code Documentation
auth_ldap_sasl_client.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef AUTH_LDAP_SASL_CLIENT_H_
24 #define AUTH_LDAP_SASL_CLIENT_H_
25 
26 #include <mysql.h>
27 #include <mysql/client_plugin.h>
28 #include <mysql/plugin.h>
30 #include <sasl/sasl.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include "log_client.h"
35 
36 #define SASL_MAX_STR_SIZE 1024
37 #define SASL_BUFFER_SIZE 9000
38 #define SASL_SERVICE_NAME "ldap"
39 
40 static const sasl_callback_t callbacks[] = {
41 #ifdef SASL_CB_GETREALM
42  {SASL_CB_GETREALM, NULL, NULL},
43 #endif
44  {SASL_CB_USER, NULL, NULL}, {SASL_CB_AUTHNAME, NULL, NULL},
45  {SASL_CB_PASS, NULL, NULL}, {SASL_CB_ECHOPROMPT, NULL, NULL},
46  {SASL_CB_NOECHOPROMPT, NULL, NULL}, {SASL_CB_LIST_END, NULL, NULL}};
47 
48 sasl_security_properties_t security_properties = {
49  /** Minimum acceptable final level. */
50  0,
51  /** Maximum acceptable final level. */
52  1,
53  /** Maximum security layer receive buffer size. */
54  0,
55  /** security flags */
56  0,
57  /** Property names. */
58  NULL,
59  /** Property values. */
60  NULL,
61 };
62 
63 class Sasl_client {
64  public:
65  Sasl_client();
66  ~Sasl_client();
67  int initilize();
69  void interact(sasl_interact_t *ilist);
71  int sasl_start(char **client_output, int *client_output_length);
72  int sasl_step(char *server_in, int server_in_length, char **client_out,
73  int *client_out_length);
74  int send_sasl_request_to_server(const unsigned char *request, int request_len,
75  unsigned char **reponse, int *response_len);
76  void set_user_info(std::string name, std::string pwd);
78 
79  protected:
87 };
88 
89 #endif // AUTH_LDAP_SASL_CLIENT_H_
Sasl_client::sasl_step
int sasl_step(char *server_in, int server_in_length, char **client_out, int *client_out_length)
Definition: auth_ldap_sasl_client.cc:263
Sasl_client::m_mysql
MYSQL * m_mysql
Definition: auth_ldap_sasl_client.h:86
NULL
#define NULL
Definition: types.h:55
plugin_auth_common.h
Sasl_client::send_sasl_request_to_server
int send_sasl_request_to_server(const unsigned char *request, int request_len, unsigned char **reponse, int *response_len)
Definition: auth_ldap_sasl_client.cc:194
string.h
mysql.h
MYSQL_PLUGIN_VIO
Provides plugin access to communication channel.
Definition: plugin_auth_common.h:140
sasl_callback
Definition: isasl.h:9
SASL_MAX_STR_SIZE
#define SASL_MAX_STR_SIZE
Definition: auth_ldap_sasl_client.h:36
Sasl_client::m_user_pwd
char m_user_pwd[SASL_MAX_STR_SIZE]
Definition: auth_ldap_sasl_client.h:81
Sasl_client::sasl_start
int sasl_start(char **client_output, int *client_output_length)
Definition: auth_ldap_sasl_client.cc:228
Sasl_client::m_user_name
char m_user_name[SASL_MAX_STR_SIZE]
Definition: auth_ldap_sasl_client.h:80
Sasl_client::m_connection
sasl_conn_t * m_connection
Definition: auth_ldap_sasl_client.h:84
SASL_CB_LIST_END
#define SASL_CB_LIST_END
Definition: isasl.h:4
Sasl_client::m_vio
MYSQL_PLUGIN_VIO * m_vio
Definition: auth_ldap_sasl_client.h:85
mysql
static MYSQL mysql
Definition: mysql.cc:152
Sasl_client
Definition: auth_ldap_sasl_client.h:63
Sasl_client::sasl_client_done_wrapper
void sasl_client_done_wrapper()
Definition: auth_ldap_sasl_client.cc:185
security_properties
sasl_security_properties_t security_properties
Definition: auth_ldap_sasl_client.h:48
Sasl_client::m_service_name
char m_service_name[SASL_MAX_STR_SIZE]
Definition: auth_ldap_sasl_client.h:83
Sasl_client::initilize
int initilize()
Definition: auth_ldap_sasl_client.cc:115
plugin.h
Sasl_client::read_method_name_from_server
int read_method_name_from_server()
SASL method is send from the Mysql server, and this is set by the client.
Definition: auth_ldap_sasl_client.cc:76
Sasl_client::set_plugin_info
void set_plugin_info(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
Definition: auth_ldap_sasl_client.cc:65
Sasl_client::set_user_info
void set_user_info(std::string name, std::string pwd)
Definition: auth_ldap_sasl_client.cc:282
Sasl_client::Sasl_client
Sasl_client()
Definition: auth_ldap_sasl_client.cc:113
Sasl_client::~Sasl_client
~Sasl_client()
Definition: auth_ldap_sasl_client.cc:177
callbacks
static const sasl_callback_t callbacks[]
Definition: auth_ldap_sasl_client.h:40
Sasl_client::m_mechanism
char m_mechanism[SASL_MAX_STR_SIZE]
Definition: auth_ldap_sasl_client.h:82
Sasl_client::interact
void interact(sasl_interact_t *ilist)
Definition: auth_ldap_sasl_client.cc:36
name
const string name("\"Name\"")
MYSQL
Definition: mysql.h:295
sasl_conn
Definition: isasl.h:15
log_client.h
client_plugin.h