Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster integration for role_store and related structures. #16926

Merged
merged 7 commits into from
Mar 12, 2024

Conversation

oleiman
Copy link
Member

@oleiman oleiman commented Mar 7, 2024

This PR introduces a new record batch type for replicated management of the in-memory role_store

model::record_batch_type::role_management_cmd governs four new controller commands:

  • create_role_cmd
  • delete_role_cmd
  • update_role_cmd
  • rename_role_cmd

Includes integration of the role_store itself into cluster::controller, cluster::security_manager as a sharded service, handlers for the commands, and cluster::security_frontend API.

Also includes a feature gate for the new commands (feature::role_based_access_control) and a fixture test for the whole kit.

Closes https://github.com/redpanda-data/core-internal/issues/1099

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x

Release Notes

  • Introduce feature::role_based_access_control

@oleiman
Copy link
Member Author

oleiman commented Mar 7, 2024

/dt

@oleiman oleiman requested a review from pgellert March 7, 2024 16:52
@oleiman oleiman force-pushed the rbac/controller-cmd branch 2 times, most recently from b4e06d3 to 948bec4 Compare March 7, 2024 17:42
@oleiman oleiman marked this pull request as ready for review March 7, 2024 17:56
src/v/cluster/security_manager.cc Outdated Show resolved Hide resolved
src/v/cluster/security_manager.cc Outdated Show resolved Hide resolved
src/v/cluster/security_frontend.cc Show resolved Hide resolved
@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Mar 7, 2024

@oleiman
Copy link
Member Author

oleiman commented Mar 7, 2024

force push for review comments

@oleiman oleiman requested a review from rockwotj March 7, 2024 20:59
rockwotj
rockwotj previously approved these changes Mar 7, 2024
Copy link
Contributor

@rockwotj rockwotj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, a couple of things I noticed on the second pass

src/v/cluster/security_manager.h Outdated Show resolved Hide resolved
ss::future<std::error_code> update_user(
security::credential_user,
security::scram_credential,
model::timeout_clock::time_point);

// Should be called ONLY on the controller leader
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it would be nice to add proper documentation to this class and these methods.

Also, by leader can we specify this needs to be the leader node, this way it's more clear that it can be called from any shard, not just shard0 on the leader.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair points

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated existing comments, but I'm going hold off full documentation of these methods for a follow-on PR. I don't want to clutter this diff up too much.

rockwotj
rockwotj previously approved these changes Mar 7, 2024
@oleiman
Copy link
Member Author

oleiman commented Mar 7, 2024

force push CR cleanups

Comment on lines 273 to 275
using create_role_cmd = controller_command<
security::role_name,
security::role,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is generally a good idea to completely ignore either the key or the value and create a versioned structure for the payload of each command to future proof yourself against needing to add additional context to the command. the rename command is a good example. sure, using key=from-name and value=to-name works now, but what if you need some extra state later? you'd probably have to add a replacement command.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmaslankaprv is there a new/better way to handle this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH we don't use the key for anything AFAIK, so I would rather just have a value and that would mean people would make their own structs for each commands, so you'd get the serde benefits. There are also things like this serde_only tag which should be the default.

I also don't love this special batch type pattern, I would rather just have the key or a header specify who owns a controller command

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serde_only is the default...noticed that yesterday and meant to remove the param in this PR.

create a versioned structure for the payload

that makes good sense, thanks. I see some examples of that pattern in nearby code now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dotnwat - this is done if you're interested in taking another look

src/v/features/feature_table.h Outdated Show resolved Hide resolved
@oleiman
Copy link
Member Author

oleiman commented Mar 8, 2024

force push contents:

  • fix required version on rbac feature spec
    • move some bits around in the test (was testing my own bug before 😛)
  • add version payload structs for role_management_cmds

Comment on lines 273 to 289
using create_role_cmd = controller_command<
int8_t, // unused
upsert_role_cmd_data,
create_role_cmd_type,
model::record_batch_type::role_management_cmd>;

using delete_role_cmd = controller_command<
int8_t, // unused
security::role_name,
delete_role_cmd_type,
model::record_batch_type::role_management_cmd>;

using update_role_cmd = controller_command<
int8_t, // unused
upsert_role_cmd_data,
update_role_cmd_type,
model::record_batch_type::role_management_cmd>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

considered collapsing create and update into one, but that would complicate the handler (and payload) somewhat. is there any reason to minimize the number of controller command types?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cant think of any reasons

@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Mar 8, 2024

new failures in https://buildkite.com/redpanda/redpanda/builds/45852#018e1d12-b6b0-4991-a079-f2a2df1caebb:

"rptest.tests.data_transforms_test.DataTransformsLoggingTest.test_logs_volume"

new failures in https://buildkite.com/redpanda/redpanda/builds/45951#018e2a36-0ec4-4da2-b568-4723fb9dfc8a:

"rptest.tests.write_caching_test.WriteCachingPropertiesTest.test_properties"

@oleiman oleiman requested review from dotnwat and rockwotj March 8, 2024 17:38
@oleiman
Copy link
Member Author

oleiman commented Mar 8, 2024

rockwotj
rockwotj previously approved these changes Mar 8, 2024
src/v/cluster/commands.h Outdated Show resolved Hide resolved
@oleiman
Copy link
Member Author

oleiman commented Mar 8, 2024

force push to add versioned delete_role_cmd_data

@oleiman oleiman requested a review from rockwotj March 8, 2024 18:18
rockwotj
rockwotj previously approved these changes Mar 8, 2024
@oleiman
Copy link
Member Author

oleiman commented Mar 10, 2024

/ci-repeat 1
skip-redpanda-build
release
skip-units

@oleiman
Copy link
Member Author

oleiman commented Mar 10, 2024

/ci-repeat 1

pgellert
pgellert previously approved these changes Mar 11, 2024
Copy link
Contributor

@pgellert pgellert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Batch type (NEW): model::record_batch_type::role_management_cmd

payload types:
  - upsert_role_cmd_data - (role_name, role)
  - rename_role_cmd_data - (role_name, role_name)
  - delete_role_cmd_data - (role_name)

controller_commands:
  - create_role_cmd - (int8_t /*unused*/, upsert_role_cmd_data)
  - delete_role_cmd - (int8_t /*unused*/, delete_role_cmd_data)
  - update_role_cmd - (int8_t /*unused*/, upsert_role_cmd_data)
  - rename_role_cmd - (int8_t /*unused*/, rename_role_cmd_data)

Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
cluster::errc {
  ...
  role_exists,          // Cmd failed because the target role exists
  role_does_not_exist,  // Cmd failed because the target role does not exist
}

Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Fixup for clang-tidy (and general preferred practice).

No functional changes.
Adds a sharded<security::role_store> to cluster::controller, which shared it
down into cluster::security_manager (alongside credential_store and authorizer).

The sharded role_store service is started and stopped by the controller in the
usual way.

Also adds controller::get_role_store.

The meat of the change is in security_manager, where high level semantics and
error handling for the various role_managment_cmds are applied.

Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
create, delete, update, rename

All requests are subject to the role_based_access_control feature gate.

This interface should be consumed ONLY on the controller leader.

Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
New file: security_frontend_test.cc

Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
@oleiman
Copy link
Member Author

oleiman commented Mar 11, 2024

force_push rebase on dev to fix feature_table merge conflict

@oleiman oleiman merged commit 8471282 into redpanda-data:dev Mar 12, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants