|
14 | 14 | #include "cluster/members_table.h" |
15 | 15 | #include "cluster/security_frontend.h" |
16 | 16 | #include "cluster_link/utils.h" |
| 17 | +#include "features/feature_table.h" |
17 | 18 | #include "kafka/data/rpc/client.h" |
18 | 19 | #include "kafka/data/rpc/serde.h" |
| 20 | +#include "security/role_store.h" |
19 | 21 |
|
20 | 22 | namespace cluster_link { |
21 | 23 |
|
22 | 24 | namespace { |
23 | 25 | class security_impl : public security_service { |
24 | 26 | public: |
25 | | - explicit security_impl(ss::sharded<cluster::security_frontend>* security_fe) |
26 | | - : _security_fe(security_fe) {} |
| 27 | + security_impl( |
| 28 | + ss::sharded<cluster::security_frontend>* security_fe, |
| 29 | + ss::sharded<security::role_store>* role_store, |
| 30 | + ss::sharded<features::feature_table>* features) |
| 31 | + : _security_fe(security_fe) |
| 32 | + , _role_store(role_store) |
| 33 | + , _features(features) {} |
| 34 | + |
27 | 35 | ss::future<chunked_vector<cluster::errc>> create_acls( |
28 | 36 | chunked_vector<security::acl_binding> bindings, |
29 | 37 | ::model::timeout_clock::duration timeout) final { |
30 | 38 | return _security_fe->local().create_acls(std::move(bindings), timeout); |
31 | 39 | } |
32 | 40 |
|
| 41 | + ss::future<std::error_code> create_role( |
| 42 | + security::role_name name, |
| 43 | + security::role role, |
| 44 | + ::model::timeout_clock::duration timeout) final { |
| 45 | + return _security_fe->local().create_role( |
| 46 | + std::move(name), |
| 47 | + std::move(role), |
| 48 | + ::model::timeout_clock::now() + timeout); |
| 49 | + } |
| 50 | + |
| 51 | + ss::future<std::error_code> update_role( |
| 52 | + security::role_name name, |
| 53 | + security::role role, |
| 54 | + ::model::timeout_clock::duration timeout) final { |
| 55 | + return _security_fe->local().update_role( |
| 56 | + std::move(name), |
| 57 | + std::move(role), |
| 58 | + ::model::timeout_clock::now() + timeout); |
| 59 | + } |
| 60 | + |
| 61 | + ss::future<std::error_code> delete_role( |
| 62 | + security::role_name name, |
| 63 | + ::model::timeout_clock::duration timeout) final { |
| 64 | + return _security_fe->local().delete_role( |
| 65 | + std::move(name), ::model::timeout_clock::now() + timeout); |
| 66 | + } |
| 67 | + |
| 68 | + bool rbac_active() const final { |
| 69 | + return _features->local().is_active( |
| 70 | + features::feature::role_based_access_control); |
| 71 | + } |
| 72 | + |
| 73 | + chunked_vector<security::role_with_members> read_shadow_roles( |
| 74 | + const std::function<bool(const security::role_name&)>& pred) const final { |
| 75 | + return _role_store->local().roles_with_members(pred); |
| 76 | + } |
| 77 | + |
33 | 78 | private: |
34 | 79 | ss::sharded<cluster::security_frontend>* _security_fe; |
| 80 | + ss::sharded<security::role_store>* _role_store; |
| 81 | + ss::sharded<features::feature_table>* _features; |
35 | 82 | }; |
36 | 83 |
|
37 | 84 | class kafka_rpc_client_impl : public kafka_rpc_client_service { |
@@ -66,8 +113,10 @@ class members_table_provider_impl : public members_table_provider { |
66 | 113 | } // namespace |
67 | 114 |
|
68 | 115 | std::unique_ptr<security_service> security_service::make_default( |
69 | | - ss::sharded<cluster::security_frontend>* security_fe) { |
70 | | - return std::make_unique<security_impl>(security_fe); |
| 116 | + ss::sharded<cluster::security_frontend>* security_fe, |
| 117 | + ss::sharded<security::role_store>* role_store, |
| 118 | + ss::sharded<features::feature_table>* features) { |
| 119 | + return std::make_unique<security_impl>(security_fe, role_store, features); |
71 | 120 | } |
72 | 121 |
|
73 | 122 | std::unique_ptr<kafka::client::cluster> |
|
0 commit comments