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

Handling of project features.* in authorization #13863

Closed
4 tasks done
markylaing opened this issue Aug 2, 2024 · 2 comments · Fixed by #13886
Closed
4 tasks done

Handling of project features.* in authorization #13863

markylaing opened this issue Aug 2, 2024 · 2 comments · Fixed by #13886
Assignees
Labels
Bug Confirmed to be a bug
Milestone

Comments

@markylaing
Copy link
Contributor

markylaing commented Aug 2, 2024

When any features.* are disabled on a project, entities of that type are created in the default project instead.

Authorization checks are made with specific entity URLs. If the authorizer is not aware that the entity may not be in the project specified by the project query parameter in the URL, the authorization check may fail with a "not found" error.

I've investigated the work that is needed for this and outlined it below:

  • In the embedded OpenFGA authorization driver, check for request.CtxEffectiveProjectName in the request context and handle appropriately.
  • For features.profiles, the effective project is only set in the request context when listing profiles. If features.profiles is disabled for a project, getting/updating/deleting a single profile in that project works because the access check is using the request project. This will not work with the OpenFGA authorization driver, so we'll need to always set the effective project in the request context.
  • For features.networks and features.networks.zones we have the same situation as with features.profiles above.
  • For features.images we have a similar situation as with features.profiles, however we need to be careful to two key areas. Firstly, the process of getting the effective project is not standardised like it is for other entity types (with a function in the lxd/project package). Secondly, the database methods for getting/listing images are quite convoluted, and reperform this check on each call. I think we'll need to refactor a bit to simplify these methods by determining the effective project beforehand and passing it in.

I will treat each item here separately and create a PR for each.

@markylaing markylaing added the Bug Confirmed to be a bug label Aug 2, 2024
@markylaing markylaing self-assigned this Aug 2, 2024
@tomponline tomponline added this to the lxd-6.2 milestone Aug 2, 2024
tomponline added a commit that referenced this issue Aug 27, 2024
Implements the following:
1. Always sets the effective project when querying entities that have
associated `features.*` project config. This includes:
i. Adding network, network zone, image, and profile specific access
handlers.
ii. For each entity type above, setting details in the request context
to avoid repeated calculation (same pattern as for storage buckets and
volumes).
2. Always uses the request project in calls to
`(Authorizer).CheckPermission` and in calls to the
`auth.PermissionChecker` returned by
`(Authorizer).GetPermissionChecker`.
3. In the TLS driver, we remove effective project handling (we always
expect calls to use the request project, this is what we check in their
allowed project list).
4. In the OpenFGA driver, overwrite the request project with the
effective project in calls to the embedded OpenFGA server. But do not
"punch through" to the default project like with the TLS driver, as
these permissions can be managed by an administrator.
5. Increased test coverage for project features with TLS authorization.
6. Adds tests for handling of project features with fine-grained
authorization.

Closes #13863
@tomponline
Copy link
Member

I will treat each item here separately and create a PR for each.

Should this issue remain open as only 1 PR has closed it?

@markylaing
Copy link
Contributor Author

I will treat each item here separately and create a PR for each.

Should this issue remain open as only 1 PR has closed it?

I had thought the PRs would be much larger but I've ticked all the bullets off here with the one PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed to be a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants