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: Pre-check permissions when performing bulk state update. #13155

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lxd/instances_put.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,21 @@ func instancesPut(d *Daemon, r *http.Request) response.Response {
return response.SmartError(err)
}

var names []string
var instances []instance.Instance
for _, inst := range c {
if inst.Project().Name != projectName {
continue
}

// Only allow changing the state of instances the user has permission for.
// Check permission for all instances so that we apply the state change to all or none.
if !userHasPermission(entity.InstanceURL(inst.Project().Name, inst.Name())) {
return response.Forbidden(nil)
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a better error to the Forbidden response?

Copy link
Contributor Author

@markylaing markylaing Mar 15, 2024

Choose a reason for hiding this comment

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

I wasn't sure what the response should be as we're attempting not to make any resources discoverable...

Maybe User does not have entitlement "can_update_state" for all instances? But then they will know that there are other instances in the project 🤔

}
}

var names []string
var instances []instance.Instance
for _, inst := range c {
if inst.Project().Name != projectName {
continue
}

Expand Down
Loading