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

Filter IC Permission Sets based on access #49936

Merged
merged 5 commits into from
Dec 12, 2024
Merged

Conversation

tcsc
Copy link
Contributor

@tcsc tcsc commented Dec 9, 2024

If a user is granted access to an IC Permission Set via an access request,
the UI treats the referenced account as if all Permission Sets are granted.
This hides the requestable Permission Sets from the user, making it
impossible for a user to requests more Permission Sets on that account.

This patch filters the Permission Sets delivered to the UI based on whether
the user already has access the Permission Sets and marks any requestable
Permission Sets on the account.

This provides the UI with enough information to decide how to display the
Permission Set list in order to get around the issue.

@tcsc tcsc added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v17 labels Dec 9, 2024
@tcsc tcsc requested review from r0mant and smallinsky December 9, 2024 14:39

// RequiresRequest indicates that the user needs to raise an access request to
// be granted this permission set
bool RequiresRequest = 4 [(gogoproto.jsontag) = "assignment_name,omitempty"];
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the RequiresRequest attribute needed for the permission_set object?

The RequiresRequest attribute is only used by the Front End. For the same flow in Okta, when an app has multiple okta_groups or AWS app access with multiple IAM configurations, the RequiresRequest attribute was not necessary apart from the top level app property and Instead, the logic riels on the top-level app.RequiresRequest flag.

So why is it handled differently in this case? For the AWS IC flow, why is the RequiresRequest flag needed for each selected object, whereas for other flows (e.g., Okta with multiple okta_groups), the logic relies on the top-level app.RequiresRequest flag?

Also does the FE is aware of this change ?
cc: @flyinghermit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could probably do this with the enriched resource, outside of the AppV3 and avoiding the protobuf change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, so the reason this needs to be in the protobuf definition is that the app representing the IC Account goes over the wire (at least logically) at some point between the Unified Resource Cache listing and being rendered to json.

As far as I can tell, we need to calculate which Account Assignments are available to (or requestable by) a user during this listing, because once we have transmitted the resource to the URC client, we no longer have the tools available to evaluate the user's access.

If we want to expose this requestability info to the UI, then we need to expose it to the Unified Resource Cache client first, and for that it has to be part of the App's wire format.

lib/auth/auth_with_roles.go Outdated Show resolved Hide resolved
lib/auth/auth_with_roles.go Outdated Show resolved Hide resolved
If a user is granted access to an IC Permission Set via an access request,
the UI treats the referenced account as if all Permission Sets are granted.
This hides the requestable Permission Sets from the user, making it
impossible for a user to requests more Permission Sets on that account.

This patch filters the Permission Sets delivered to the UI based on whether
the user already has access the Permission Sets and marks any requestable
Permission Sets on the account.

This provides the UI with enough information to decide how to display the
Permission Set list in order to get around the issue.
@tcsc tcsc force-pushed the tcsc/idc-filter-permission-sets branch from 155d548 to 5b55287 Compare December 11, 2024 15:01
@tcsc tcsc marked this pull request as ready for review December 11, 2024 15:12
lib/auth/auth_with_roles.go Show resolved Hide resolved
lib/auth/auth_with_roles.go Outdated Show resolved Hide resolved
@@ -472,7 +472,7 @@ func (a *AppV3) GetDisplayName() string {
if a.Spec.IdentityCenter == nil {
return ""
}
return a.GetName()
return a.Metadata.Description
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is not related to "Filter IC Permission Sets based on access" right ?

Just want to make sure that this is not leftover from local stash.

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 needed to change the name value of the "app" to be the account ID - for two reasons:

  1. so I can pull it out to build the dummy Account Assignment that we use to query access
  2. to avoid the uniqueness issues we discussed yesterday

The knock-on effect of this is that the friendly name is now pulled from the app description.

continue
}
output = append(output, ps)
if _, requestable := checker.requestableMap[ps.AssignmentID]; requestable {
Copy link
Contributor

@smallinsky smallinsky Dec 11, 2024

Choose a reason for hiding this comment

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

Why the checker.requestableMap map is updated here? This filterICPermissionSets function is called after the checker.requestableMap map is used in

paginatedResources, err := services.MakePaginatedResources(ctx, types.KindUnifiedResource, unifiedResources, resourceAccess.requestableMap)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The access check for the AccountAssignment on line 1530 modifies the requestableMap as a side effect, and that's how we pull out whether the assignment requires an Access Request.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, Thanks. I had in mind the previous logic model but for this flow where the checker.checkAccess is reused that makes sens.


var output []*types.IdentityCenterPermissionSet
for _, ps := range pss {
assignment.Metadata.Name = ps.AssignmentID
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the assignment.Metadata.Name needs to be updated. Does the checker.checkAccess RBAC check depends on the resource name ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - when it writes to the requestable map

@tcsc tcsc added this pull request to the merge queue Dec 12, 2024
Merged via the queue into master with commit b3fbbc2 Dec 12, 2024
42 checks passed
@tcsc tcsc deleted the tcsc/idc-filter-permission-sets branch December 12, 2024 23:10
@public-teleport-github-review-bot

@tcsc See the table below for backport results.

Branch Result
branch/v17 Failed

tcsc added a commit that referenced this pull request Dec 13, 2024
Backports #49936

If a user is granted access to an IC Permission Set via an access request,
the UI treats the referenced account as if all Permission Sets are granted.
This hides the requestable Permission Sets from the user, making it
impossible for a user to requests more Permission Sets on that account.

This patch filters the Permission Sets delivered to the UI based on whether
the user already has access the Permission Sets and marks any requestable
Permission Sets on the account.

This provides the UI with enough information to decide how to display the
Permission Set list in order to get around the issue.

---------

Co-authored-by: Marek Smoliński <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Dec 13, 2024
* [v17] Filter IC Permission Sets based on access

Backports #49936

If a user is granted access to an IC Permission Set via an access request,
the UI treats the referenced account as if all Permission Sets are granted.
This hides the requestable Permission Sets from the user, making it
impossible for a user to requests more Permission Sets on that account.

This patch filters the Permission Sets delivered to the UI based on whether
the user already has access the Permission Sets and marks any requestable
Permission Sets on the account.

This provides the UI with enough information to decide how to display the
Permission Set list in order to get around the issue.

---------

Co-authored-by: Marek Smoliński <[email protected]>

* fix bad cherrypick

---------

Co-authored-by: Marek Smoliński <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws-iam-identity-center backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants