MySQL 9.3.0
Source Code Documentation
authorize_manager.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2021, 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_INTERFACE_AUTHORIZE_MANAGER_H_
27#define ROUTER_SRC_REST_MRS_SRC_MRS_INTERFACE_AUTHORIZE_MANAGER_H_
28
29#include <memory>
30#include <string>
31#include <vector>
32
33#include "helper/mysql_time.h"
37#include "mrs/http/cookie.h"
41
42#include "http/base/headers.h"
43
44namespace collector {
45
47
48} // namespace collector
49
50namespace mrs {
51
52namespace rest {
53struct RequestContext;
54} // namespace rest
55
56namespace interface {
57
59 public:
64 using AuthorizeHandlerPtr = std::shared_ptr<AuthorizeHandler>;
65 using AuthHandlers = std::vector<AuthorizeHandlerPtr>;
68 using Entries = std::vector<AuthApp>;
70 using Container = std::vector<AuthorizeHandlerPtr>;
73
74 virtual ~AuthorizeManager() = default;
75
76 virtual void update(const Entries &entries) = 0;
77
78 virtual bool authorize(const std::string &proto, const std::string &host,
80 AuthUser *out_user) = 0;
82 AuthUser *user) = 0;
83 virtual bool unauthorize(const SessionPtr &session,
84 http::Cookie *cookies) = 0;
85 virtual void configure(const std::string &options) = 0;
86 virtual std::string get_jwt_token(ServiceId service_id,
87 const SessionPtr &s) = 0;
88
91
93
95 virtual void clear() = 0;
96 virtual void update_users_cache(const ChangedUsersIds &changed_users_ids) = 0;
97};
98
99} // namespace interface
100} // namespace mrs
101
102#endif // ROUTER_SRC_REST_MRS_SRC_MRS_INTERFACE_AUTHORIZE_MANAGER_H_
Definition: cache_manager.h:41
Definition: mysql_cache_manager.h:87
MySqlCacheManager::CachedObject CachedObject
Definition: mysql_cache_manager.h:92
headers of a HTTP response/request.
Definition: headers.h:43
Definition: cookie.h:38
Definition: session_manager.h:64
std::string SessionId
Definition: session_manager.h:51
std::shared_ptr< Session > SessionPtr
Definition: session_manager.h:143
Definition: authorize_manager.h:58
std::vector< AuthorizeHandlerPtr > Container
Definition: authorize_manager.h:70
virtual std::string get_jwt_token(ServiceId service_id, const SessionPtr &s)=0
http::SessionManager::SessionId SessionId
Definition: authorize_manager.h:60
virtual bool is_authorized(ServiceId id, rest::RequestContext &ctxt, AuthUser *user)=0
virtual bool authorize(const std::string &proto, const std::string &host, ServiceId id, rest::RequestContext &ctxt, AuthUser *out_user)=0
std::shared_ptr< AuthorizeHandler > AuthorizeHandlerPtr
Definition: authorize_manager.h:64
virtual void configure(const std::string &options)=0
std::vector< AuthorizeHandlerPtr > AuthHandlers
Definition: authorize_manager.h:65
virtual collector::MysqlCacheManager * get_cache()=0
database::entry::AuthUser AuthUser
Definition: authorize_manager.h:67
std::vector< AuthApp > Entries
Definition: authorize_manager.h:68
virtual users::UserManager * get_user_manager()=0
virtual ~AuthorizeManager()=default
virtual bool unauthorize(const SessionPtr &session, http::Cookie *cookies)=0
virtual void discard_current_session(ServiceId, http::Cookie *)
Definition: authorize_manager.h:92
UniversalId ServiceId
Definition: authorize_manager.h:69
virtual void update_users_cache(const ChangedUsersIds &changed_users_ids)=0
mrs::users::UserManager::ChangedUsersIds ChangedUsersIds
Definition: authorize_manager.h:72
http::SessionManager::SessionPtr SessionPtr
Definition: authorize_manager.h:62
virtual void update(const Entries &entries)=0
database::entry::AuthApp AuthApp
Definition: authorize_manager.h:66
virtual Container get_supported_authentication_applications(ServiceId id)=0
Definition: user_manager.h:41
std::vector< std::pair< database::entry::UniversalId, std::string > > ChangedUsersIds
Definition: user_manager.h:51
const char * host
Definition: mysqladmin.cc:66
Definition: cache_manager.h:33
Request::Headers Headers
Definition: request.cc:34
mrs::database::entry::AuthApp AuthApp
Definition: oauth2_handler.cc:58
mrs::database::entry::AuthUser AuthUser
Definition: scram_handler.cc:54
AuthorizeManager::Session Session
Definition: authorize_manager.cc:75
collector::MysqlCacheManager MysqlCacheManager
Definition: handler_db_object_table.cc:266
Definition: authorize_manager.h:48
mrs::database::entry::UniversalId UniversalId
Definition: universal_id.h:33
Definition: options.cc:57
Definition: request_context.h:47