ORE Studio 0.0.4
Loading...
Searching...
No Matches
authorization_protocol.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_IAM_MESSAGING_AUTHORIZATION_PROTOCOL_HPP
21#define ORES_IAM_MESSAGING_AUTHORIZATION_PROTOCOL_HPP
22
23#include <optional>
24#include <string>
25#include <string_view>
26#include <vector>
27#include "ores.iam.api/domain/role.hpp"
28#include "ores.iam.api/domain/permission.hpp"
29
30namespace ores::iam::messaging {
31
32struct list_roles_request {
33 using response_type = struct list_roles_response;
34 static constexpr std::string_view nats_subject = "iam.v1.roles.list";
35};
36
37struct list_roles_response {
38 std::vector<ores::iam::domain::role> roles;
39};
40
41struct list_permissions_request {};
42
43struct list_permissions_response {
44 std::vector<ores::iam::domain::permission> permissions;
45};
46
47struct get_role_request {
48 std::string identifier;
49};
50
51struct get_role_response {
52 bool found = false;
53 std::optional<ores::iam::domain::role> role;
54 std::string error_message;
55};
56
57struct assign_role_request {
58 using response_type = struct assign_role_response;
59 static constexpr std::string_view nats_subject = "iam.v1.roles.assign";
60 std::string account_id;
61 std::string role_id;
62};
63
64struct assign_role_response {
65 bool success = false;
66 std::string error_message;
67};
68
69struct assign_role_by_name_response {
70 bool success = false;
71 std::string error_message;
72};
73
74struct assign_role_by_name_request {
75 using response_type = struct assign_role_by_name_response;
76 static constexpr std::string_view nats_subject = "iam.v1.roles.assign-by-name";
77 std::string principal;
78 std::string role_name;
79};
80
81struct revoke_role_request {
82 using response_type = struct revoke_role_response;
83 static constexpr std::string_view nats_subject = "iam.v1.roles.revoke";
84 std::string account_id;
85 std::string role_id;
86};
87
88struct revoke_role_response {
89 bool success = false;
90 std::string error_message;
91};
92
93struct revoke_role_by_name_response {
94 bool success = false;
95 std::string error_message;
96};
97
98struct revoke_role_by_name_request {
99 using response_type = struct revoke_role_by_name_response;
100 static constexpr std::string_view nats_subject = "iam.v1.roles.revoke-by-name";
101 std::string principal;
102 std::string role_name;
103};
104
105struct get_account_roles_request {
106 using response_type = struct get_account_roles_response;
107 static constexpr std::string_view nats_subject = "iam.v1.roles.by-account";
108 std::string account_id;
109};
110
111struct get_account_roles_response {
112 std::vector<ores::iam::domain::role> roles;
113};
114
115struct get_account_permissions_request {
116 std::string account_id;
117};
118
119struct get_account_permissions_response {
120 std::vector<std::string> permission_codes;
121};
122
123struct suggest_role_commands_request {
124 using response_type = struct suggest_role_commands_response;
125 static constexpr std::string_view nats_subject = "iam.v1.roles.suggest-commands";
126 std::string username;
127 std::string tenant_id;
128 std::string hostname;
129};
130
131struct suggest_role_commands_response {
132 std::vector<std::string> commands;
133};
134
135}
136
137#endif
Well-known permission codes used throughout the system.
Definition permission.hpp:78