- Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathaccount_verification_handler.h
124 lines (104 loc) · 4.81 KB
/
account_verification_handler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* Copyright (c) 2017, 2025, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0,
* as published by the Free Software Foundation.
*
* This program is designed to work with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an additional
* permission to link the program and your derivative works with the
* separately licensed software that they have either included with
* the program or referenced in the documentation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLUGIN_X_SRC_ACCOUNT_VERIFICATION_HANDLER_H_
#definePLUGIN_X_SRC_ACCOUNT_VERIFICATION_HANDLER_H_
#include<map>
#include<memory>
#include<string>
#include"plugin/x/src/interface/account_verification.h"
#include"plugin/x/src/interface/account_verification_handler.h"
#include"plugin/x/src/interface/authentication.h"
#include"plugin/x/src/interface/session.h"
#include"plugin/x/src/ngs/error_code.h"
#include"plugin/x/src/sql_user_require.h"
namespacexpl {
classAccount_verification_handler
: public iface::Account_verification_handler {
public:
using Unique_ptr = std::unique_ptr<Account_verification_handler>;
explicitAccount_verification_handler(iface::Session *session)
: m_session(session) {}
Account_verification_handler(
iface::Session *session,
const iface::Account_verification::Account_type account_type,
iface::Account_verification *verificator)
: m_session(session), m_account_type(account_type) {
add_account_verificator(account_type, verificator);
}
ngs::Error_code authenticate(const iface::Authentication &account_verificator,
iface::Authentication_info *authenication_info,
const std::string &sasl_message) constoverride;
ngs::Error_code verify_account(
const std::string &user, const std::string &host,
const std::string &passwd,
const iface::Authentication_info *authenication_info) constoverride;
voidadd_account_verificator(
const iface::Account_verification::Account_type account_type,
iface::Account_verification *verificator) {
m_verificators[account_type].reset(verificator);
}
const iface::Account_verification *get_account_verificator(
const iface::Account_verification::Account_type account_type)
constoverride;
staticboolparse_sasl_message(
const std::string &sasl_message,
iface::Authentication_info *out_authentication_info,
std::string *out_schema, std::string *out_account,
std::string *out_passwd);
private:
using Account_verificator_list =
std::map<iface::Account_verification::Account_type,
std::unique_ptr<iface::Account_verification>>;
structAccount_record {
bool require_secure_transport{true};
std::string db_password_hash;
std::string auth_plugin_name;
bool is_account_locked{true};
bool is_password_expired{true};
bool disconnect_on_expired_password{true};
bool is_offline_mode_and_not_super_user{true};
Sql_user_require user_required;
};
staticboolextract_sub_message(const std::string &message,
std::size_t &element_position,
std::string &sub_message);
staticboolextract_last_sub_message(const std::string &message,
std::size_t &element_position,
std::string &sub_message);
iface::Account_verification::Account_type get_account_verificator_id(
const std::string &plugin_name) const;
ngs::Error_code get_offline_mode_error() const;
ngs::Error_code get_account_record(const std::string &user,
const std::string &host,
Account_record &record) const;
ngs::PFS_string get_sql(const std::string &user,
const std::string &host) const;
iface::Session *m_session;
Account_verificator_list m_verificators;
iface::Account_verification::Account_type m_account_type =
iface::Account_verification::Account_type::k_unsupported;
};
} // namespace xpl
#endif// PLUGIN_X_SRC_ACCOUNT_VERIFICATION_HANDLER_H_