MySQL 9.3.0
Source Code Documentation
auth_app.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_DATABASE_ENTRY_AUTH_APP_H_
27#define ROUTER_SRC_REST_MRS_SRC_MRS_DATABASE_ENTRY_AUTH_APP_H_
28
29#include <set>
30#include <vector>
31
33
35#include "helper/optional.h"
36
37namespace mrs {
38namespace database {
39namespace entry {
40
41class AuthApp {
42 public:
44 std::set<UniversalId> service_ids;
46 std::string vendor_name;
47 std::string app_name;
48 bool active;
49 bool deleted;
50 std::string url;
51 std::string url_validation;
52 std::string app_id;
53 std::string app_token;
54 std::string url_access_token;
57};
58
61 stt.add_value(reinterpret_cast<const char *>(&id.raw[0]), id.k_size,
63 return stt;
64}
65
66inline std::string to_string(const AuthApp &entry) {
67 const char *k_default_role_id = "default_role_id";
69 {
70 auto obj = stt.add_object();
71 stt.member_add_value("id", "0x" + entry.id.to_string());
72 {
73 auto arr = stt.member_add_array("service_id");
74 for (const auto &id : entry.service_ids) {
75 *arr << ("0x" + id.to_string());
76 }
77 }
78 stt.member_add_value("name", entry.vendor_name);
79 stt.member_add_value("limit_to_registered_users",
80 entry.limit_to_registered_users);
81 if (!entry.url.empty()) {
82 stt.member_add_value("url", entry.url);
83 }
84
85 if (!entry.url_access_token.empty()) {
86 stt.member_add_value("url_access_token", entry.url_access_token);
87 }
88
89 if (!entry.url_validation.empty()) {
90 stt.member_add_value("url_validation", entry.url_validation);
91 }
92
93 if (entry.default_role_id.has_value())
94 stt.member_add_value(k_default_role_id,
95 "0x" + entry.default_role_id.value().to_string());
96 else
97 stt.member_add_null_value(k_default_role_id);
98 }
99
100 return stt.get_result();
101}
102
103} // namespace entry
104} // namespace database
105} // namespace mrs
106
107#endif // ROUTER_SRC_REST_MRS_SRC_MRS_DATABASE_ENTRY_AUTH_APP_H_
Lightweight implementation of optional.
Definition: optional.h:39
Definition: serializer_to_text.h:45
SerializerToText & add_value(const char *value, JsonType ct=JsonType::kString)
Definition: serializer_to_text.h:197
std::string get_result()
Definition: serializer_to_text.h:137
Object add_object()
Definition: serializer_to_text.h:142
SerializerToText & member_add_null_value(const Str1 &key)
Definition: serializer_to_text.h:287
SerializerToText & member_add_value(const Str1 &key, const Str2 &value, JsonType ct)
Definition: serializer_to_text.h:258
Array member_add_array(const char *key)
Definition: serializer_to_text.h:247
Definition: auth_app.h:41
std::string app_name
Definition: auth_app.h:47
std::string vendor_name
Definition: auth_app.h:46
UniversalId id
Definition: auth_app.h:43
std::string app_token
Definition: auth_app.h:53
bool active
Definition: auth_app.h:48
std::string url_access_token
Definition: auth_app.h:54
std::string app_id
Definition: auth_app.h:52
UniversalId vendor_id
Definition: auth_app.h:45
std::string url
Definition: auth_app.h:50
helper::Optional< UniversalId > default_role_id
Definition: auth_app.h:56
std::string url_validation
Definition: auth_app.h:51
std::set< UniversalId > service_ids
Definition: auth_app.h:44
bool limit_to_registered_users
Definition: auth_app.h:55
bool deleted
Definition: auth_app.h:49
@ kString
Definition: mysql_column_types.h:35
helper::json::SerializerToText & operator<<(helper::json::SerializerToText &stt, const UniversalId &id)
Definition: auth_app.h:59
std::string to_string(const AuthApp &entry)
Definition: auth_app.h:66
Definition: authorize_manager.h:48
Definition: completion_hash.h:35
Definition: universal_id.h:45