MySQL 8.3.0
Source Code Documentation
http_auth_realm_component.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef MYSQLROUTER_HTTP_AUTH_REALM_COMPONENT_INCLUDED
26#define MYSQLROUTER_HTTP_AUTH_REALM_COMPONENT_INCLUDED
27
28#include <map>
29#include <memory>
30#include <mutex>
31#include <string>
32#include <system_error>
33
35
36class HttpAuthRealm;
37
38/**
39 * public API of HttpAuthRealm plugin.
40 */
42 public:
43 using value_type = std::map<std::string, std::shared_ptr<HttpAuthRealm>>;
44
45 /**
46 * get singleton instance of the component.
47 */
48 static HttpAuthRealmComponent &get_instance();
49
50 /**
51 * register a realm with a handler.
52 */
53 void add_realm(const std::string &name, std::shared_ptr<HttpAuthRealm> realm);
54
55 /**
56 * unregister a realm.
57 */
58 void remove_realm(const std::string &name);
59
60 /**
61 * authenticate user with authdata against realm.
62 *
63 * @param inst instance name of realm
64 * @param username name of user to authenticate
65 * @param authdata credentials of user
66 * @returns error
67 * @retval false authentication without error.
68 */
69 std::error_code authenticate(const std::string &inst,
70 const std::string &username,
71 const std::string &authdata);
72
73 /**
74 * get realm by instance name.
75 */
76 std::shared_ptr<HttpAuthRealm> get(const std::string &inst);
77
78 private:
79 // disable copy, as we are a single-instance
81 void operator=(HttpAuthRealmComponent const &) = delete;
82
83 std::mutex realms_m_;
85
87};
88
89#endif
public API of HttpAuthRealm plugin.
Definition: http_auth_realm_component.h:41
value_type auth_realms_
Definition: http_auth_realm_component.h:84
HttpAuthRealmComponent(HttpAuthRealmComponent const &)=delete
std::map< std::string, std::shared_ptr< HttpAuthRealm > > value_type
Definition: http_auth_realm_component.h:43
void operator=(HttpAuthRealmComponent const &)=delete
HttpAuthRealmComponent()=default
std::mutex realms_m_
Definition: http_auth_realm_component.h:83
Authentication Realm.
Definition: http_auth_realm.h:46
#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:31
case opt name
Definition: sslopt-case.h:32