MySQL 9.0.0
Source Code Documentation
http_auth_backend_component.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018, 2024, 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_HTTP_INCLUDE_MYSQLROUTER_COMPONENT_HTTP_AUTH_BACKEND_COMPONENT_H_
27#define ROUTER_SRC_HTTP_INCLUDE_MYSQLROUTER_COMPONENT_HTTP_AUTH_BACKEND_COMPONENT_H_
28
29#include <map>
30#include <memory>
31#include <mutex>
32#include <string>
33#include <system_error>
34
36
37class HttpAuthBackend;
38
39/**
40 * public API of the HttpAuthBackend plugin.
41 */
43 public:
44 using value_type = std::map<std::string, std::shared_ptr<HttpAuthBackend>>;
45
46 /**
47 * get instance of Component.
48 */
49 static HttpAuthBackendComponent &get_instance();
50
51 /**
52 * register an authentication backend.
53 */
54 void add_backend(const std::string &name,
55 std::shared_ptr<HttpAuthBackend> backend);
56
57 /**
58 * unregister an authentication backend.
59 */
60 void remove_backend(const std::string &name);
61
62 /**
63 * authenticate user against auth-backend.
64 *
65 * @returns error
66 * @retval false authentication without error.
67 */
68 std::error_code authenticate(const std::string &inst,
69 const std::string &username,
70 const std::string &authdata);
71
72 private:
73 // disable copy, as we are a single-instance
75 void operator=(HttpAuthBackendComponent const &) = delete;
76
77 std::mutex backends_m_;
79
81};
82
83#endif // ROUTER_SRC_HTTP_INCLUDE_MYSQLROUTER_COMPONENT_HTTP_AUTH_BACKEND_COMPONENT_H_
public API of the HttpAuthBackend plugin.
Definition: http_auth_backend_component.h:42
value_type auth_backends_
Definition: http_auth_backend_component.h:78
void operator=(HttpAuthBackendComponent const &)=delete
HttpAuthBackendComponent()=default
std::map< std::string, std::shared_ptr< HttpAuthBackend > > value_type
Definition: http_auth_backend_component.h:44
HttpAuthBackendComponent(HttpAuthBackendComponent const &)=delete
std::mutex backends_m_
Definition: http_auth_backend_component.h:77
Base class of all AuthBackends.
Definition: http_auth_backend.h:45
#define HTTP_AUTH_BACKEND_LIB_EXPORT
Definition: http_auth_backend_lib_export.h:15
case opt name
Definition: sslopt-case.h:29