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

Setting ACL with UpdateACL couldn't work #180

Open
ybizeul opened this issue Nov 24, 2024 · 0 comments
Open

Setting ACL with UpdateACL couldn't work #180

ybizeul opened this issue Nov 24, 2024 · 0 comments

Comments

@ybizeul
Copy link

ybizeul commented Nov 24, 2024

I was trying to use func (c *Client) UpdateACL(ctx context.Context, acl ACL) error to add ACLs to a Pool.

Something like :

	var acl pmx.ACL

	acl = pmx.ACL{
		RoleID:    "PVEPoolAdmin",
		UGID:      fmt.Sprintf("%[email protected]", pool),
		Propagate: true,
		Path:      fmt.Sprintf("/pool/%s", pool),
		Type:      "user",
	}

	s, err := json.Marshal(acl)
	slog.Info(string(s))

	err = p.client.UpdateACL(context.Background(), acl)
	if err != nil {
		slog.Error("Error updating acl", slog.String("acl", fmt.Sprintf("%+v", acl)), slog.String("error", err.Error()))
	}

It seems that can't be used, and is being sent as-is to /access/acl, without proper lowercase on map keys (see missing key in tags at

Path string `json:",omitempty"`
), and it wouldn't work any ways because the proper way to update ACLs would be :
image

I ended up doing this, which works fine :

	acl := struct {
		Path      string `json:"path"`
		Roles     string `json:"roles"`
		Users     string `json:"users"`
		Propagate bool   `json:"propagate"`
	}{
		Path:      fmt.Sprintf("/pool/%s", pool),
		Roles:     "PVEVMAdmin,PVEPoolAdmin",
		Users:     fmt.Sprintf("%[email protected]", pool),
		Propagate: true,
	}

	err = p.client.Put(context.Background(), "/access/acl", acl, nil)
	if err != nil {
		slog.Error("Error updating ACL", slog.String("acl", fmt.Sprintf("%+v", acl)), slog.String("error", err.Error()))
	}

Maybe I'm doing something wrong, using a wrong API version somehow ?

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

No branches or pull requests

1 participant