MySQL  8.0.19
Source Code Documentation
roles.h
Go to the documentation of this file.
1 /* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef ROLES_H_INCLUDED
24 #define ROLES_H_INCLUDED
25 
26 // Forward declarations
27 class THD;
28 struct LEX_USER;
29 template <class T>
30 class List;
31 class Security_context;
32 enum class role_enum;
33 
34 namespace Roles {
36  public:
37  explicit Role_activation(THD *thd, Security_context *sctx, role_enum type,
38  const List<LEX_USER> *role_list = nullptr,
39  bool raise_error = true);
40  Role_activation(const Role_activation &) = delete;
41  Role_activation(Role_activation &&) = delete;
42  Role_activation &operator=(const Role_activation &) = delete;
44  ~Role_activation() { m_valid = false; }
45 
46  bool activate();
47 
48  private:
49  bool activate_role_none();
50  bool activate_role_default();
51  bool activate_role_all();
52  bool activate_role_name();
53 
54  private:
60  bool m_valid;
61 };
62 } // namespace Roles
63 
64 #endif /* ROLES_H_INCLUDED */
Roles::Role_activation::m_type
role_enum m_type
Definition: roles.h:57
Roles::Role_activation::m_raise_error
bool m_raise_error
Definition: roles.h:59
THD
Definition: sql_class.h:764
Roles::Role_activation::operator=
Role_activation & operator=(const Role_activation &)=delete
Roles::Role_activation::Role_activation
Role_activation(THD *thd, Security_context *sctx, role_enum type, const List< LEX_USER > *role_list=nullptr, bool raise_error=true)
Constructor.
Definition: roles.cc:51
Roles::Role_activation::activate_role_none
bool activate_role_none()
Deactivate all roles for current session.
Definition: roles.cc:101
Roles::Role_activation::activate_role_all
bool activate_role_all()
Activate all granted roles - except those specified through m_role_list.
Definition: roles.cc:193
Roles::Role_activation::m_sctx
Security_context * m_sctx
Definition: roles.h:56
LEX_USER
Definition: table.h:2366
role_enum
role_enum
Definition: sql_admin.h:217
Roles::Role_activation::m_role_list
const List< LEX_USER > * m_role_list
Definition: roles.h:58
Roles::Role_activation::activate_role_default
bool activate_role_default()
Activate default roles for current session.
Definition: roles.cc:126
Roles::Role_activation
Definition: roles.h:35
Roles::Role_activation::~Role_activation
~Role_activation()
Definition: roles.h:44
Roles::Role_activation::activate_role_name
bool activate_role_name()
Activate roles available through m_role_list.
Definition: roles.cc:281
Roles::Role_activation::m_thd
THD * m_thd
Definition: roles.h:55
Roles::Role_activation::activate
bool activate()
Activate roles for given session.
Definition: roles.cc:73
Roles::Role_activation::m_valid
bool m_valid
Definition: roles.h:60
HttpMethod::type
int type
Definition: http_common.h:411
Roles
Definition: roles.cc:40
List
Definition: aggregate_check.h:523
Security_context
A set of THD members describing the current authenticated user.
Definition: sql_security_ctx.h:53