From 5c2bf8642f88069c0a8c1094bcb5409a73150aaf Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Mon, 1 Jul 2019 16:40:02 +0200 Subject: [PATCH] gateway: show run/tasks/steps if the project is public If the project is public don't require the user to be logged in to show the run/tasks/logs --- internal/services/gateway/action/auth.go | 6 +++--- internal/services/gateway/gateway.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/services/gateway/action/auth.go b/internal/services/gateway/action/auth.go index f991e1a..dd53349 100644 --- a/internal/services/gateway/action/auth.go +++ b/internal/services/gateway/action/auth.go @@ -194,13 +194,13 @@ func (h *ActionHandler) CanGetRun(ctx context.Context, runGroup string) (bool, e visibility = types.VisibilityPrivate } + if visibility == types.VisibilityPublic { + return true, nil + } isProjectMember, err := h.IsProjectMember(ctx, ownerType, ownerID) if err != nil { return false, errors.Errorf("failed to determine ownership: %w", err) } - if visibility == types.VisibilityPublic { - return true, nil - } if !isProjectMember { return false, nil } diff --git a/internal/services/gateway/gateway.go b/internal/services/gateway/gateway.go index ac87fe1..818b947 100644 --- a/internal/services/gateway/gateway.go +++ b/internal/services/gateway/gateway.go @@ -286,9 +286,9 @@ func (g *Gateway) Run(ctx context.Context) error { apirouter.Handle("/orgs/{orgref}/members/{userref}", authForcedHandler(addOrgMemberHandler)).Methods("PUT") apirouter.Handle("/orgs/{orgref}/members/{userref}", authForcedHandler(removeOrgMemberHandler)).Methods("DELETE") - apirouter.Handle("/runs/{runid}", authForcedHandler(runHandler)).Methods("GET") + apirouter.Handle("/runs/{runid}", authOptionalHandler(runHandler)).Methods("GET") apirouter.Handle("/runs/{runid}/actions", authForcedHandler(runActionsHandler)).Methods("PUT") - apirouter.Handle("/runs/{runid}/tasks/{taskid}", authForcedHandler(runtaskHandler)).Methods("GET") + apirouter.Handle("/runs/{runid}/tasks/{taskid}", authOptionalHandler(runtaskHandler)).Methods("GET") apirouter.Handle("/runs/{runid}/tasks/{taskid}/actions", authForcedHandler(runTaskActionsHandler)).Methods("PUT") apirouter.Handle("/runs", authForcedHandler(runsHandler)).Methods("GET")