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

RBAC: Adding action set resolver (action set read path) #86801

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

IevaVasiljeva
Copy link
Contributor

@IevaVasiljeva IevaVasiljeva commented Apr 23, 2024

What is this feature?

Adding action set resolver.

Why do we need this feature?

We are transitioning over to using action sets when storing resource permissions in a DB instead of storing each individual permission.

We added logic to store action sets in #86108. This PR adds logic to consider action sets when we check for users permissions. Eg, when checking if a user has the permission folders:write, we check folders:write as well as folders:edit and folders:admin (the latter two being action sets).

This is done by adding an action set resolver, that expands the evaluator to include action sets, so evaluator checking folders:view becomes an evaluator checking any(folders:view folders:edit folders:admin folders:read) (the scope remains unchanged).

Who is this feature for?

Currently internal only (behind accessActionSets feature toggle).

Which issue(s) does this PR fix?:

Fixes https://github.com/grafana/identity-access-team/issues/662

Special notes for your reviewer:

OSS counter part: https://github.com/grafana/grafana-enterprise/pull/6574

@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.1.x milestone Apr 23, 2024
@IevaVasiljeva IevaVasiljeva added no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes and removed area/backend labels Apr 23, 2024
actionSets map[string][]string
log log.Logger
actionSetsToActions map[string][]string
actionsToActionSets map[string][]string
Copy link
Contributor

Choose a reason for hiding this comment

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

change this from actionsToActionSets since we are taking in a action and not multiple actions

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 feel like this is a matter of preference on whether to use plural or singular for map naming. I usually go for a plural (my thinking is - we are creating a mapping between actions and action sets, which will hold several entries, so plural makes sense). But I don't have a strong preference as long as we're consistent. So if you feel strongly about actionToActionSets instead of actionsToActionSets, we should also go with actionSetToActions instead of actionSetsToActions.

@IevaVasiljeva IevaVasiljeva marked this pull request as ready for review May 2, 2024 16:12
@IevaVasiljeva IevaVasiljeva requested a review from a team as a code owner May 2, 2024 16:12
Comment on lines +69 to +71
if features.IsEnabled(context.Background(), featuremgmt.FlagAccessActionSets) {
actionSetService.StoreActionSet(options.Resource, permission, actions)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: putting this behind a feature toggle - there shouldn't be anything risky with registering an action set, but better safe than sorry.

@grafanabot
Copy link
Contributor

❌ Failed to run Playwright plugin e2e tests.

Click here to browse the Playwright report and trace viewer.
For information on how to run Playwright tests locally, refer to the Developer guide.

@IevaVasiljeva IevaVasiljeva requested review from a team as code owners May 3, 2024 10:14
@IevaVasiljeva IevaVasiljeva requested review from rwwiv, JacobsonMT, yuri-tceretian and grobinson-grafana and removed request for a team May 3, 2024 10:14
@@ -48,6 +49,11 @@ func (a *AccessControl) Evaluate(ctx context.Context, user identity.Requester, e
return false, nil
}

// TODO update this to use featuremgmt.FeatureToggles instead of checking the config
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will tackle this in a separate PR, as it will involve a lot of test changes, and I don't want to add noise to this PR.

@@ -1,12 +1,17 @@
package acimpl
package acimpl_test
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renaming to avoid import cycles

@@ -1,4 +1,4 @@
package database
package database_test
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renaming to avoid import cycles

@IevaVasiljeva IevaVasiljeva requested a review from a team as a code owner May 3, 2024 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants