Skip to content

[CORE-15198] security/role: Add group role member type#29217

Merged
nguyen-andrew merged 3 commits into
redpanda-data:devfrom
nguyen-andrew:group-role-member-type
Jan 12, 2026
Merged

[CORE-15198] security/role: Add group role member type#29217
nguyen-andrew merged 3 commits into
redpanda-data:devfrom
nguyen-andrew:group-role-member-type

Conversation

@nguyen-andrew

@nguyen-andrew nguyen-andrew commented Jan 9, 2026

Copy link
Copy Markdown
Member

This PR adds internal support for groups as role members in preparation for follow-on work to enable administrators to actually bind groups to roles.

The role system previously only supported users as role members. This PR extends the internal role membership type system to include groups, laying the groundwork for future admin API features that will allow administrators to assign groups to roles. While the admin API does not yet expose this functionality, the core role system can now represent and handle group memberships.

Backports Required

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

Release Notes

  • none

The original `role_store_test.cc` was a little complex, and a previous
tree-wide change broke the original intent of some tests (e.g., the
original `role_store_test` had a test for a "moved" role that
was actually being copied). This commit refactors the role & role store
tests to improve clarity and maintainability by minimizing each test to
only validate a single behavior.

Changes:
- Extract role-specific tests into new role_test.cc file
- Replace monolithic tests with focused, fixture-based tests
- Use descriptive test names that clearly state expected behavior
- Add detailed BOOST_CHECK_MESSAGE assertions

Unit test coverage for roles/role store is maintained or improved while
making the tests easier to understand, extend, and debug.
Adds role_member_type::group alongside the existing user type to
support groups as role members. Includes the corresponding operator<<
overload for string representation and updated related tests.
Maps principal_type::group to role_member_type::group in the
member_type_for_principal_type function, allowing group principals
to be converted to role members. Updates relevant tests to cover this
new mapping.
@nguyen-andrew nguyen-andrew requested a review from a team January 9, 2026 22:44
@nguyen-andrew nguyen-andrew self-assigned this Jan 9, 2026
@nguyen-andrew nguyen-andrew requested review from IoannisRP and Copilot and removed request for a team January 9, 2026 22:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends Redpanda's internal role membership type system to support groups as role members, alongside the existing user support. This is preparatory infrastructure work that enables groups to be assigned to roles, though the admin API functionality to actually bind groups to roles is not yet exposed.

Changes:

  • Added group as a new role_member_type enum value
  • Implemented formatting and conversion logic for group role members
  • Added comprehensive unit tests for role member operations including group support

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/v/security/role.h Adds group enum value to role_member_type and declares stream operator
src/v/security/role.cc Implements group handling in principal type conversion and stream output
src/v/security/tests/role_test.cc New test file covering role member creation, formatting, and type conversions for both users and groups
src/v/security/tests/role_store_test.cc Refactors existing tests into fixture-based structure with improved clarity and coverage
src/v/security/tests/BUILD Adds new role_test target and removes unused dependencies from role_store_test

Comment on lines +27 to +30
absl::node_hash_set<role_name>
make_role_name_set(const role_store::roles_range& range) {
return {range.begin(), range.end()};
}

Copilot AI Jan 9, 2026

Copy link

Choose a reason for hiding this comment

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

Add a docstring explaining the purpose of this helper function, as it is used throughout multiple test cases to convert ranges to sets for assertion checking.

Copilot uses AI. Check for mistakes.
@vbotbuildovich

Copy link
Copy Markdown
Collaborator

CI test results

test results on build#78845
test_class test_method test_arguments test_kind job_url test_status passed reason test_history
ControllerForcedReconfiguration_Size5 test_cluster_recovery {"scenario": "Simple"} integration https://buildkite.com/redpanda/redpanda/builds/78845#019ba501-de33-4917-a59d-1a0fb6d9b036 FLAKY 10/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0465, p0=1.0000, reject_threshold=0.0100. adj_baseline=0.1331, p1=0.2396, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=ControllerForcedReconfiguration_Size5&test_method=test_cluster_recovery
RedpandaNodeOperationsSmokeTest test_node_ops_smoke_test {"cloud_storage_type": 1, "mixed_versions": false} integration https://buildkite.com/redpanda/redpanda/builds/78845#019ba501-de37-4bbb-bef8-5109f4da914e FLAKY 9/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.1169, p0=0.7115, reject_threshold=0.0100. adj_baseline=0.3113, p1=0.1325, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=RedpandaNodeOperationsSmokeTest&test_method=test_node_ops_smoke_test

@IoannisRP IoannisRP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

BOOST_AUTO_TEST_CASE(role_format_includes_all_members) {
const role_member mem0{role_member_type::user, "member0"};
const role_member mem1{role_member_type::user, "member1"};
const role_member mem1{role_member_type::group, "group0"};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit:

Instead of replacing member1 with group0, append group0 to the set.

@IoannisRP

Copy link
Copy Markdown
Contributor

@nguyen-andrew
Cover is duplicated.

@nguyen-andrew nguyen-andrew merged commit 031a45b into redpanda-data:dev Jan 12, 2026
21 checks passed
@nguyen-andrew nguyen-andrew deleted the group-role-member-type branch January 12, 2026 16:57
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.

4 participants