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

auth: Add entitlements to LXD resources (part 3: Enrich LXD resources with entitlements) #14748

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

Conversation

gabrielmougard
Copy link
Contributor

test/suites/auth.sh Fixed Show fixed Hide fixed
test/suites/auth.sh Fixed Show fixed Hide fixed
test/suites/auth.sh Fixed Show fixed Hide fixed
test/suites/auth.sh Fixed Show fixed Hide fixed
@gabrielmougard gabrielmougard force-pushed the feat/auth-dry-run-check-part3 branch 2 times, most recently from e653ad9 to 7f5457a Compare January 8, 2025 21:09
@gabrielmougard gabrielmougard marked this pull request as ready for review January 8, 2025 21:09
@gabrielmougard gabrielmougard force-pushed the feat/auth-dry-run-check-part3 branch 2 times, most recently from 171b326 to 1a09849 Compare January 9, 2025 13:09
lxd/instance_get.go Outdated Show resolved Hide resolved
lxd/auth/types.go Outdated Show resolved Hide resolved
lxd/instances_get.go Outdated Show resolved Hide resolved
@gabrielmougard gabrielmougard force-pushed the feat/auth-dry-run-check-part3 branch from 1a09849 to e18b874 Compare January 10, 2025 08:44
@gabrielmougard
Copy link
Contributor Author

@minaelee thanks for the feedbacks. Fixing that right now

Adds `fine_grained` field to `GET /1.0/auth/identities/current` to indicate if the current identity
interacting with the LXD API is fine-grained (i.e, associated permissions are managed via group membership) and
allow LXD entities to be returned with an `entitlements` field if the current identity is fine-grained and if the
GET request to fetch the LXD entities has the `with-entitlements=<comma_separated_list_of_candidate_entitlements>` query parameter.

Signed-off-by: Gabriel Mougard <[email protected]>
Signed-off-by: Gabriel Mougard <[email protected]>
@gabrielmougard gabrielmougard force-pushed the feat/auth-dry-run-check-part3 branch 3 times, most recently from b265876 to 6f763e7 Compare January 10, 2025 14:27
@gabrielmougard gabrielmougard force-pushed the feat/auth-dry-run-check-part3 branch from 6f763e7 to c793358 Compare January 10, 2025 14:28
Copy link
Contributor

@edlerd edlerd left a comment

Choose a reason for hiding this comment

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

Approach and format seems all right from my point of view. Left some comments below.

shared/api/image.go Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we add a test case like the one below?

A restricted user has some entitlements on a project. Request the project list with that user and with a list of entitlements. Then assert the api response contains the correct list of entitlements for that project. Maybe request some entitlements the user has on the project, and some that the user has not to make it cover all the possible cases.

If we build this test case reusable, we can repeat it for all the different entity types, but not sure if that level of coverage is needed.

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, that seems like a good test case. I can try to build a reusable one for a couple of entities (instance, volume, or other ones you think might be useful for your use case)

…ies/current` endpoint

This is needed to let know the client if the currently used identity is fine-grained or not.

Signed-off-by: Gabriel Mougard <[email protected]>
@gabrielmougard gabrielmougard force-pushed the feat/auth-dry-run-check-part3 branch from c793358 to ed0cbfa Compare January 10, 2025 17:01
… current identity info

Signed-off-by: Gabriel Mougard <[email protected]>
…e `Authorizer` interface

These methods return the entitlements corresponding to the entity/entities through calls to the
OpenFGA datastore. These functions should be called at the end of a LXD API handler so that the
OpenFGA per-request cache can be hit.

Signed-off-by: Gabriel Mougard <[email protected]>
… eligible LXD entities

Signed-off-by: Gabriel Mougard <[email protected]>
Signed-off-by: Gabriel Mougard <[email protected]>
@gabrielmougard gabrielmougard force-pushed the feat/auth-dry-run-check-part3 branch from ed0cbfa to 6725a64 Compare January 10, 2025 17:08
@@ -623,6 +623,12 @@ func storagePoolVolumesGet(d *Daemon, r *http.Request) response.Response {
return response.SmartError(err)
}

// Detect if we want to also returns entitlements for each volume.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Detect if we want to also returns entitlements for each volume.
// Detect if we want to also return entitlements for each volume.

@@ -2016,6 +2035,12 @@ func storagePoolVolumeGet(d *Daemon, r *http.Request) response.Response {
return response.SmartError(err)
}

// Detect if we want to also returns entitlements for each volume.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Detect if we want to also returns entitlements for each volume.
// Detect if we want to also return entitlements for each volume.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Changes to the REST API Documentation Documentation needs updating
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants