The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/5095
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Stéphane Graber <[email protected]>
From f12d912d23ad90e277286999d76d6fdef93bf19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]> Date: Tue, 2 Oct 2018 17:26:43 -0400 Subject: [PATCH] candid: Cleanup code a bit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <[email protected]> --- lxc/remote.go | 3 +-- lxd/daemon.go | 18 +++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lxc/remote.go b/lxc/remote.go index 3a418af9b0..d359a38728 100644 --- a/lxc/remote.go +++ b/lxc/remote.go @@ -235,8 +235,7 @@ func (c *cmdRemoteAdd) Run(cmd *cobra.Command, args []string) error { uri.RawQuery = query.Encode() } - fmt.Println(uri) - return nil + return httpbakery.OpenWebBrowser(uri) }, }, }) diff --git a/lxd/daemon.go b/lxd/daemon.go index 2a94c65cf9..5f670d29a8 100644 --- a/lxd/daemon.go +++ b/lxd/daemon.go @@ -182,9 +182,13 @@ func (d *Daemon) checkTrustedClient(r *http.Request) error { if d.externalAuth != nil && r.Header.Get(httpbakery.BakeryProtocolHeader) != "" { ctx := httpbakery.ContextWithRequest(context.TODO(), r) - authChecker := d.externalAuth.bakery.Checker.Auth( - httpbakery.RequestMacaroons(r)...) - ops := getBakeryOps(r) + authChecker := d.externalAuth.bakery.Checker.Auth(httpbakery.RequestMacaroons(r)...) + + ops := []bakery.Op{{ + Entity: r.URL.Path, + Action: r.Method, + }} + _, err := authChecker.Allow(ctx, ops...) return err } @@ -198,14 +202,6 @@ func (d *Daemon) checkTrustedClient(r *http.Request) error { return fmt.Errorf("unauthorized") } -// Return the bakery operations implied by the given HTTP request -func getBakeryOps(r *http.Request) []bakery.Op { - return []bakery.Op{{ - Entity: r.URL.Path, - Action: r.Method, - }} -} - func writeMacaroonsRequiredResponse(b *identchecker.Bakery, r *http.Request, w http.ResponseWriter, derr *bakery.DischargeRequiredError, expiry int64) { ctx := httpbakery.ContextWithRequest(context.TODO(), r) caveats := append(derr.Caveats,
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
