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

Honor child scope list permissions when recursing #1016

Merged
merged 9 commits into from
Mar 24, 2021
Merged

Honor child scope list permissions when recursing #1016

merged 9 commits into from
Mar 24, 2021

Conversation

jefferai
Copy link
Member

Current behavior is that you need list grant on the parent scope when
recursively listing, and this is sufficient. This is good for
administrative workflows but can be unintuitive for resources that only
exist at a project level. This change allows permissions on the child
scope to also be taken into account, so that you can start a recursive
list from a parent scope without direct list support on that scope but
still get back child scopes for which list access is granted.

This also fixes a bug where visibility of a scope for recursive listing
would be based on whether the user had list resources for roles within
that scope instead of for the resource type in question.

Current behavior is that you need list grant on the parent scope when
recursively listing, and this is sufficient. This is good for
administrative workflows but can be unintuitive for resources that only
exist at a project level. This change allows permissions on the child
scope to also be taken into account, so that you can start a recursive
list from a parent scope without direct list support on that scope but
still get back child scopes for which list access is granted.

This also fixes a bug where visibility of a scope for recursive listing
would be based on whether the user had list resources for roles within
that scope instead of for the resource type in question.
@jefferai jefferai marked this pull request as ready for review March 19, 2021 17:47
Copy link
Collaborator

@jimlambrt jimlambrt left a comment

Choose a reason for hiding this comment

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

just a few suggestions.

internal/servers/controller/common/scopeids/scope_ids.go Outdated Show resolved Hide resolved
// If it's forbidden, and it's a recursive request, and they're
// successfully authenticated but just not authorized, keep going as we
// may have authorization on downstream scopes.
if authResults.Error == handlers.ForbiddenError() &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a anyway to provide a func that combines authResults(...) and GetScopeIds(...) that could be used in all the List functions? It seems like this block is going to be copied quite a bit.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do that as a follow after this PR. I wanted to keep changes minimal (as opposed to additions) for easy reviewing.

Copy link
Collaborator

@jimlambrt jimlambrt left a comment

Choose a reason for hiding this comment

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

In this PR the changes to: Internal/common/scopeids/scope_ids.go have no unit tests.

There are quite a few missing unit tests in the packages touched by this PR. I’m not suggesting that all these missing tests be addressed in this PR, but we should note them and address them in future PRs:

  • internal/auth/auth.go could use some better coverage for things like the recovery KMS code branches.
  • internal/perms/options.go -> it might be nice to have unit tests for these options
  • internal/servers/controller/handlers/errors.go -> no unit tests for NotFoundError(), Is(..), ApiErrorWithCode(…), ForbiddenError(…), UnauthenticatedError()
  • internal/servers/controller/handlers/mask_manager.go -> no units for MaskContains(…)
  • internal/servers/controller/handlers/outgoing_interceptor.go -> OutgoingInterceptor(…) missing tests for the case where *pbs.AuthenticateLoginResponse
  • internal/servers/controller/handlers/authmethods/authmethods_service.go -> currently no unit tests for Service.AuthenticateLogin(…)
  • internal/servers/controller/handlers/targets/target_service.go -> currently no unit tests for Service.AuthorizeSession(…)

@jefferai
Copy link
Member Author

@jimlambrt As discussed, updated the tests. They can be simplified more -- right now I haven't changed the logic to copy part of the group service code -- but at this point that's merely cleanup as the test just goes further than it needs to. So it's ready for another look.

@jefferai jefferai requested a review from jimlambrt March 22, 2021 21:13
Copy link
Contributor

@talanknight talanknight left a comment

Choose a reason for hiding this comment

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

Looks good. Just wanting to figure out my 1 question regarding resources that aren't allowed in a specific scope, otherwise LGTM.

talanknight
talanknight previously approved these changes Mar 23, 2021
Copy link
Collaborator

@jimlambrt jimlambrt left a comment

Choose a reason for hiding this comment

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

Looks great!

@jefferai jefferai merged commit aa570f4 into main Mar 24, 2021
@jefferai jefferai deleted the ICU-1236 branch March 24, 2021 19:33
@jefferai jefferai modified the milestones: 0.1.9, 0.2.0 Apr 14, 2021
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.

3 participants