Skip to content

feat(iam): add user groups for policy attachment#619

Open
poyrazK wants to merge 5 commits into
mainfrom
release/iam-user-groups
Open

feat(iam): add user groups for policy attachment#619
poyrazK wants to merge 5 commits into
mainfrom
release/iam-user-groups

Conversation

@poyrazK

@poyrazK poyrazK commented May 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implements IAM User Groups (GitHub issue IAM: Implement user groups and group-based policy attachment #608) — adds user groups as a new IAM primitive for organizing users and assigning policies collectively
  • Adds groups, user_groups, and group_policies database tables via migration 114
  • Adds Group, UserGroup, and GroupPolicy domain models
  • Adds group CRUD operations, membership management (add/remove user from group), and group-policy attachment/detachment at the repository, service, and handler layers
  • Integrates group policies into the RBAC authorization flow via checkGroupIAMPolicies() — group policies are evaluated after user-attached and role-attached policies
  • Adds HTTP endpoints: POST/GET/PUT/DELETE /iam/groups, POST/DELETE/GET /iam/groups/:id/members/:userId, POST/DELETE/GET /iam/groups/:id/policies/:policyId

Test plan

  • Run migration: goose postgres \"postgres://...\" up
  • Create a group: POST /iam/groups with {\"name\": \"engineering\"}
  • Add user to group: POST /iam/groups/{id}/members/{userId}
  • Attach policy to group: POST /iam/groups/{id}/policies/{policyId}
  • Verify user inherits group-attached policy permissions via RBAC authorization
  • Remove user from group and verify access is revoked
  • Run existing tests: go test ./internal/core/services/... ./internal/repositories/postgres/... (note: mocks will need regeneration for new interface methods)

poyrazK added 5 commits May 19, 2026 20:07
Implements GitHub issue #608 - user groups for IAM policy management.
Adds three new database tables (groups, user_groups, group_policies),
Group domain model, and all supporting repository/service/handler methods
for CRUD operations and policy attachment.
Adds CreateGroup, GetGroupByID, ListGroups, UpdateGroup, DeleteGroup,
AddUserToGroup, RemoveUserFromGroup, GetGroupsForUser, GetUsersInGroup,
AttachPolicyToGroup, DetachPolicyFromGroup, GetPoliciesForGroup methods
to the IAMRepository interface, IAMService interface, and iamService implementation.
Implements all group-related methods in iamRepository:
CreateGroup, GetGroupByID, ListGroups, UpdateGroup, DeleteGroup,
AddUserToGroup, RemoveUserFromGroup, GetGroupsForUser, GetUsersInGroup,
AttachPolicyToGroup, DetachPolicyFromGroup, GetPoliciesForGroup, GetGroupsForPolicy.
Adds checkGroupIAMPolicies() method to rbacService that resolves a user's
group memberships and evaluates IAM policies attached to those groups.
Group policies are checked after user-attached and role-attached policies
in the HasPermission authorization chain.
Adds all group HTTP handlers (CreateGroup, ListGroups, GetGroupByID,
UpdateGroup, DeleteGroup, AddUserToGroup, RemoveUserFromGroup,
GetGroupMembers, AttachPolicyToGroup, DetachPolicyFromGroup,
GetGroupPolicies) and registers them in the IAM router group.

Breaks a naming conflict with autoscaling_handler by renaming
CreateGroupRequest/UpdateGroupRequest to IAMGroupRequest.
Copilot AI review requested due to automatic review settings May 19, 2026 17:08
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@poyrazK has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 23 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2bb3fdc7-539d-4f20-85ff-3fe245bccaa0

📥 Commits

Reviewing files that changed from the base of the PR and between f907852 and 69a7d70.

📒 Files selected for processing (9)
  • internal/api/setup/router.go
  • internal/core/domain/group.go
  • internal/core/ports/iam.go
  • internal/core/services/iam.go
  • internal/core/services/rbac.go
  • internal/handlers/iam_handler.go
  • internal/repositories/postgres/iam_repo.go
  • internal/repositories/postgres/migrations/114_create_user_groups_and_group_policies.down.sql
  • internal/repositories/postgres/migrations/114_create_user_groups_and_group_policies.up.sql
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch release/iam-user-groups

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

2 participants