[lxc-devel] [lxd/master] lxd/rbac: Fix URL encoding

stgraber on Github lxc-bot at linuxcontainers.org
Fri Nov 6 00:30:49 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201105/26c66bc7/attachment.bin>
-------------- next part --------------
From a2b128ba369a101127cf2e3e0967b17a70ea8c7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 5 Nov 2020 19:30:32 -0500
Subject: [PATCH] lxd/rbac: Fix URL encoding
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/rbac/server.go | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lxd/rbac/server.go b/lxd/rbac/server.go
index 444882c097..4259c0fa8e 100644
--- a/lxd/rbac/server.go
+++ b/lxd/rbac/server.go
@@ -387,7 +387,10 @@ func (r *Server) syncAdmin(username string) bool {
 		return false
 	}
 
-	u.Path = path.Join(u.Path, fmt.Sprintf("api/service/v1/resources/lxd/permissions-for-user?u=%s", username))
+	values := url.Values{}
+	values.Set("u", username)
+	u.RawQuery = values.Encode()
+	u.Path = path.Join(u.Path, "/api/service/v1/resources/lxd/permissions-for-user")
 
 	req, err := http.NewRequest("GET", u.String(), nil)
 	if err != nil {
@@ -416,7 +419,10 @@ func (r *Server) syncPermissions(username string) error {
 		return err
 	}
 
-	u.Path = path.Join(u.Path, fmt.Sprintf("/api/service/v1/resources/project/permissions-for-user?u=%s", username))
+	values := url.Values{}
+	values.Set("u", username)
+	u.RawQuery = values.Encode()
+	u.Path = path.Join(u.Path, "/api/service/v1/resources/project/permissions-for-user")
 
 	req, err := http.NewRequest("GET", u.String(), nil)
 	if err != nil {


More information about the lxc-devel mailing list