MySQL 8.4.2
Source Code Documentation
http_auth_realm_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_REALM_COMPONENT_H_
27#define ROUTER_SRC_HTTP_INCLUDE_MYSQLROUTER_COMPONENT_HTTP_AUTH_REALM_COMPONENT_H_
28
29#include <map>
30#include <memory>
31#include <mutex>
32#include <string>
33#include <system_error>
34
36
37class HttpAuthRealm;
38
39/**
40 * public API of HttpAuthRealm plugin.
41 */
43 public:
44 using value_type = std::map<std::string, std::shared_ptr<HttpAuthRealm>>;
45
46 /**
47 * get singleton instance of the component.
48 */
49 static HttpAuthRealmComponent &get_instance();
50
51 /**
52 * register a realm with a handler.
53 */
54 void add_realm(const std::string &name, std::shared_ptr<HttpAuthRealm> realm);
55
56 /**
57 * unregister a realm.
58 */
59 void remove_realm(const std::string &name);
60
61 /**
62 * authenticate user with authdata against realm.
63 *
64 * @param inst instance name of realm
65 * @param username name of user to authenticate
66 * @param authdata credentials of user
67 * @returns error
68 * @retval false authentication without error.
69 */
70 std::error_code authenticate(const std::string &inst,
71 const std::string &username,
72 const std::string &authdata);
73
74 /**
75 * get realm by instance name.
76 */
77 std::shared_ptr<HttpAuthRealm> get(const std::string &inst);
78
79 private:
80 // disable copy, as we are a single-instance
82 void operator=(HttpAuthRealmComponent const &) = delete;
83
84 std::mutex realms_m_;
86
88};
89
90#endif // ROUTER_SRC_HTTP_INCLUDE_MYSQLROUTER_COMPONENT_HTTP_AUTH_REALM_COMPONENT_H_
public API of HttpAuthRealm plugin.
Definition: http_auth_realm_component.h:42
value_type auth_realms_
Definition: http_auth_realm_component.h:85
HttpAuthRealmComponent(HttpAuthRealmComponent const &)=delete
std::map< std::string, std::shared_ptr< HttpAuthRealm > > value_type
Definition: http_auth_realm_component.h:44
void operator=(HttpAuthRealmComponent const &)=delete
HttpAuthRealmComponent()=default
std::mutex realms_m_
Definition: http_auth_realm_component.h:84
Authentication Realm.
Definition: http_auth_realm.h:47
#define HTTP_AUTH_REALM_LIB_EXPORT
Definition: http_auth_realm_lib_export.h:15
void get(PSI_field *, PSI_longlong *) noexcept
Definition: pfs_plugin_column_bigint_v1_all_empty.cc:32
case opt name
Definition: sslopt-case.h:29