MySQL 9.3.0
Source Code Documentation
sasl_handler.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2023, 2025, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#ifndef ROUTER_SRC_REST_MRS_SRC_MRS_AUTHENTICATION_SASL_HANDLER_H_
27#define ROUTER_SRC_REST_MRS_SRC_MRS_AUTHENTICATION_SASL_HANDLER_H_
28
29#include <chrono>
30#include <functional>
31#include <memory>
32#include <optional>
33#include <string>
34#include <vector>
35
36#include "helper/http/url.h"
38#include "http/base/method.h"
44
45namespace mrs {
46namespace authentication {
47
49 protected:
52 using duration = std::chrono::steady_clock::duration;
54 using steady_clock = std::chrono::steady_clock;
55 using time_point = std::chrono::steady_clock::time_point;
63
64 public:
70 };
71
73 public:
75 bool session_id_set{false};
77
79 };
80
81 public:
83
84 const AuthApp &get_entry() const override;
85 std::set<UniversalId> get_service_ids() const override;
86 UniversalId get_id() const override;
87
88 virtual std::unique_ptr<SessionData> allocate_session_data() = 0;
89 bool redirects(RequestContext &ctxt) const override;
90 bool authorize(RequestContext &ctxt, const SessionPtr &session,
91 AuthUser *out_user) override;
92
93 struct SaslResult {
95
97
100
103 };
104
105 struct SaslData {
107 std::string auth_data;
109 };
110
112 const UrlParameters &parameters, const bool has_auth_data);
113
115 RequestContext &ctxt, Session *session, AuthUser *out_user) = 0;
117 Session *session,
118 AuthUser *out_user,
119 const std::string &auth_data,
120 const bool is_json) = 0;
122 AuthUser *out_user,
123 const std::string &auth_data,
124 const bool is_json) = 0;
125
126 UserManager &get_user_manager() override { return um_; }
127
128 protected:
132};
133
134} // namespace authentication
135} // namespace mrs
136
137#endif // ROUTER_SRC_REST_MRS_SRC_MRS_AUTHENTICATION_SASL_HANDLER_H_
Definition: variant_pointer.h:34
HttpUri::QueryElements Parameters
Definition: url.h:51
seconds expires
Definition: sasl_handler.h:74
AuthenticationState sasl_state
Definition: sasl_handler.h:78
time_point acquired_at
Definition: sasl_handler.h:76
bool session_id_set
Definition: sasl_handler.h:75
Definition: sasl_handler.h:48
mrs::interface::QueryFactory QueryFactory
Definition: sasl_handler.h:62
helper::http::Url::Parameters UrlParameters
Definition: sasl_handler.h:60
std::chrono::steady_clock steady_clock
Definition: sasl_handler.h:54
std::chrono::steady_clock::duration duration
Definition: sasl_handler.h:52
const AuthApp & get_entry() const override
Definition: sasl_handler.cc:87
bool redirects(RequestContext &ctxt) const override
Definition: sasl_handler.cc:91
std::chrono::seconds seconds
Definition: sasl_handler.h:53
virtual SaslResult client_request_authentication_exchange(RequestContext &ctxt, Session *session, AuthUser *out_user)=0
::http::base::method::key_type HttpMethodType
Definition: sasl_handler.h:56
UserManager & get_user_manager() override
Definition: sasl_handler.h:126
std::set< UniversalId > get_service_ids() const override
Definition: sasl_handler.cc:83
virtual std::unique_ptr< SessionData > allocate_session_data()=0
virtual SaslResult client_response(RequestContext &ctxt, Session *session, AuthUser *out_user, const std::string &auth_data, const bool is_json)=0
UniversalId get_id() const override
Definition: sasl_handler.cc:89
SaslData get_authorize_data(RequestContext &ctxt)
Definition: sasl_handler.cc:132
virtual AuthenticationState get_authentication_state(const UrlParameters &parameters, const bool has_auth_data)
Definition: sasl_handler.cc:114
SaslHandler(const AuthApp &entry, QueryFactory *qf)
Definition: sasl_handler.cc:77
bool authorize(RequestContext &ctxt, const SessionPtr &session, AuthUser *out_user) override
Definition: sasl_handler.cc:160
AuthApp entry_
Definition: sasl_handler.h:130
virtual SaslResult client_initial_response(RequestContext &ctxt, Session *session, AuthUser *out_user, const std::string &auth_data, const bool is_json)=0
UserManager um_
Definition: sasl_handler.h:131
AuthenticationState
Definition: sasl_handler.h:65
@ AuthenticationStateInvalid
Definition: sasl_handler.h:69
@ AuthenticationStateExchange
Definition: sasl_handler.h:66
@ AuthenticationStateInitialResponse
Definition: sasl_handler.h:67
@ AuthenticationStateResponse
Definition: sasl_handler.h:68
std::chrono::steady_clock::time_point time_point
Definition: sasl_handler.h:55
Definition: session_manager.h:66
Definition: session_manager.h:64
Definition: session_manager.h:48
Definition: authorize_handler.h:53
mrs::database::entry::AuthUser AuthUser
Definition: authorize_handler.h:56
http::SessionManager::SessionPtr SessionPtr
Definition: authorize_handler.h:60
mrs::database::entry::AuthApp AuthApp
Definition: authorize_handler.h:57
rest::RequestContext RequestContext
Definition: authorize_handler.h:58
Definition: query_factory.h:55
Definition: user_manager.h:41
mrs::rest::Handler::HttpResult HttpResult
Definition: handler_content_file.cc:43
int key_type
Definition: method.h:38
mrs::database::entry::AuthApp AuthApp
Definition: oauth2_handler.cc:58
std::chrono::seconds seconds
Definition: authorize_manager.cc:69
Definition: authorize_manager.h:48
mrs::database::entry::UniversalId UniversalId
Definition: universal_id.h:33
Definition: completion_hash.h:35
Definition: sasl_handler.h:105
AuthenticationState state
Definition: sasl_handler.h:106
bool is_json
Definition: sasl_handler.h:108
std::string auth_data
Definition: sasl_handler.h:107
SaslResult(HttpResult result)
Definition: sasl_handler.h:98
Type response_type
Definition: sasl_handler.h:101
HttpResult http_result
Definition: sasl_handler.h:102
@ SaslOk
Definition: sasl_handler.h:94
@ SaslHttpStatusCode
Definition: sasl_handler.h:94
@ SaslChallanage
Definition: sasl_handler.h:94
SaslResult()
Definition: sasl_handler.h:96
Definition: http_result.h:37
Definition: request_context.h:47
Definition: result.h:30