8000 Add role owner view for expiring roles page by eguerrant · Pull Request #300 · discord/access · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add role owner view for expiring roles page #300

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

Merged
merged 4 commits into from
Jun 30, 2025
Merged

Conversation

eguerrant
Copy link
Contributor

Prior to having role requests, it didn't make much sense to have a view under Expiring Roles that would show role owners the access expiring soon for roles they own because we could not make that knowledge actionable.

This new view shows role owners the roles they own with access expiring soon along with the ability to make a role request for that expiring access from that page (similar to how the 'My Access' tab under Expiring Groups allows users to make access requests for their expiring access).

Related to #299 (adding role owner expiring access notifications)

Screenshot 2025-06-18 at 5 12 05 PM

@eguerrant eguerrant mentioned this pull request Jun 19, 2025
@eguerrant eguerrant marked this pull request as ready for review June 19, 2025 00:23
@savathoon savathoon requested a review from Copilot June 24, 2025 15:41
Copilot

This comment was marked as outdated.

@@ -157,10 +158,16 @@ export default function NavItems(props: NavItemsProps) {
<List disablePadding>
<ListItemLink
to="/expiring-roles?owner_id=@me"
displayText="Owned by Me"
displayText="Owned Groups"
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain a little bit the distinction between /expiring-groups?owner_id=@me and /expiring-roles?owner_id=@me? I'm not clear what the difference is.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe the difference is:

  • /expiring-groups?owner_id=@me is for group owners with individuals with expiring ownership/membership
  • /expiring-roles?owner_id=@me is for role owners with groups with expiring ownership/membership

Copy link
Contributor

Choose a reason for hiding this comment

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

ah so something like "groups owned by a role I own"? I don't want to block on this but thanks for clarifying

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had a little trouble figuring out how to explain it in like less than 15ish characters (so it fit in the menu bar) but essentially :

/expiring-groups?owner_id=@me shows a group owner when individuals' access to groups they own are expiring.

/expiring-roles?owner_id=@me shows a group owner when roles' access to groups they own are expiring.

/expiring-roles?role_owner_id=@me shows a role owner_ when roles they own will be losing access to a group soon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing 'Owned by Me' under Expiring Roles to 'Owned Groups' and 'Owned Roles' was meant to differentiate the two cases since both involve ownership. I left 'Owned by Me' under Expiring Groups alone since that seemed clear enough there

savathoon
savathoon previously approved these changes Jun 24, 2025
Copy link
Contributor
@savathoon savathoon left a comment

Choose a reason for hiding this comment

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

One nit due to not sure what the intended behavior should be here but otherwise no issues from me

@eguerrant 8000 eguerrant dismissed stale reviews from somethingnew2-0 and savathoon via 1b725c0 June 26, 2025 22:38
@eguerrant eguerrant force-pushed the expiring_roles_update branch from a1f886e to 1b725c0 Compare June 26, 2025 22:38
@savathoon savathoon requested a review from Copilot June 26, 2025 22:45
Copy link
@Copilot Copilot AI left a comment

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 adds a view and API support for role owners to see and request renewal of expiring role access.

  • Introduces a new role_owner_id query parameter throughout frontend and backend.
  • Adds a “Owned Roles” nav link and integrates CreateRoleRequest buttons in the Expiring Roles page.
  • Extends the audit endpoint, schema, and Swagger spec to filter by role_owner_id.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/pages/roles/Expiring.tsx Added role_owner_id state, query handling, and request button
src/pages/role_requests/Create.tsx Refined permission logic and updated group prop types
src/components/NavItems.tsx Added "Owned Roles" navigation item
src/api/apiComponents.ts Added role_owner_id to GetGroupRoleAuditsQueryParams
api/views/schemas/pagination.py Included role_owner_id in pagination request schema
api/views/resources/audit.py Implemented role_owner_id filtering in audit resource
api/swagger.json Added role_owner_id parameter to Swagger spec
Comments suppressed due to low confidence (1)

src/pages/role_requests/Create.tsx:522

  • The new logic enforces role-based permission but removed the original group-manager check, which means group requests may now render for unauthorized users. Restore a branch for (props.group != null && canManageGroup(...)) to keep hiding requests for groups the user manages.
    (props.role != null && !canManageGroup(props.currentUser, props.role)) ||

@@ -402,6 +406,16 @@ export default function ExpiringRoless() {
rereview={row.should_expire}
/>
</TableCell>
) : roleOwnerId || canManageGroup(currentUser, row.role_group) ? (
Copy link
Preview
Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

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

The conditional shows the CreateRoleRequest button whenever any role_owner_id is present or the user can manage the group, rather than checking if the current row’s role is actually owned by the user. Update it to roleOwnerId && row.is_owner (or similar) to ensure the button only appears for roles the user owns.

Suggested change
) : roleOwnerId || canManageGroup(currentUser, row.role_group) ? (
) : (roleOwnerId && row.is_owner) || canManageGroup(currentUser, row.role_group) ? (

Copilot uses AI. Check for mistakes.

# https://stackoverflow.com/questions/4186062/sqlalchemy-order-by-descending#comment52902932_9964966
query = query.filter(
RoleGroupMap.role_group_id.in_(
[o.group_id for o in owner_role_ownerships.with_entities(OktaUserGroupMember.group_id).all()]
Copy link
Preview
Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

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

Loading all owner role IDs into Python and then filtering can be inefficient for large datasets. Consider using a subquery—e.g., owner_role_ownerships.with_entities(...).subquery()—and pass that directly into .in_() to let the database handle filtering.

Suggested change
[o.group_id for o in owner_role_ownerships.with_entities(OktaUserGroupMember.group_id).all()]
owner_role_ownerships.with_entities(OktaUserGroupMember.group_id).subquery()

Copilot uses AI. Check for mistakes.

@eguerrant eguerrant merged commit 0907467 into main Jun 30, 2025
6 checks passed
@eguerrant eguerrant deleted the expiring_roles_update branch June 30, 2025 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging t 39A0 his pull request may close these issues.

3 participants
0