| Index: milo/appengine/buildbot/build.go
|
| diff --git a/milo/appengine/buildbot/build.go b/milo/appengine/buildbot/build.go
|
| index da6149f1ba18dbb590abe2867e611399511bdffb..f021ea0727fed9c0bfffcb3bc156ff2e70b431b8 100644
|
| --- a/milo/appengine/buildbot/build.go
|
| +++ b/milo/appengine/buildbot/build.go
|
| @@ -20,6 +20,8 @@ import (
|
| "github.com/luci/luci-go/milo/api/resp"
|
| "github.com/luci/luci-go/milo/appengine/settings"
|
| "github.com/luci/luci-go/milo/common/miloerror"
|
| + "github.com/luci/luci-go/server/auth"
|
| + "github.com/luci/luci-go/server/auth/identity"
|
| "golang.org/x/net/context"
|
| )
|
|
|
| @@ -29,17 +31,30 @@ var errBuildNotFound = miloerror.Error{
|
| }
|
|
|
| // getBuild fetches a buildbot build from the datastore and checks ACLs.
|
| +// The return code matches the master responses, that is:
|
| +// User not logged in, master found, master public: 200
|
| +// User not logged in, master not found: 401
|
| +// User not logged in, master internal: 401
|
| +// User logged in, master found, master internal: 200
|
| +// User logged in, master not found: 404
|
| +// User logged in, master found, master internal: 404
|
| +// Other error: 500
|
| func getBuild(c context.Context, master, builder string, buildNum int) (*buildbotBuild, error) {
|
| result := &buildbotBuild{
|
| Master: master,
|
| Buildername: builder,
|
| Number: buildNum,
|
| }
|
| + cu := auth.CurrentUser(c)
|
|
|
| err := ds.Get(c, result)
|
| switch {
|
| case err == ds.ErrNoSuchEntity:
|
| - return nil, errBuildNotFound
|
| + if cu.Identity == identity.AnonymousIdentity {
|
| + return nil, errNotAuth
|
| + } else {
|
| + return nil, errBuildNotFound
|
| + }
|
| case err != nil:
|
| return nil, err
|
| }
|
| @@ -49,7 +64,11 @@ func getBuild(c context.Context, master, builder string, buildNum int) (*buildbo
|
| return nil, err
|
| }
|
| if !allowed {
|
| - return nil, errBuildNotFound
|
| + if cu.Identity == identity.AnonymousIdentity {
|
| + return nil, errNotAuth
|
| + } else {
|
| + return nil, errBuildNotFound
|
| + }
|
| }
|
| }
|
|
|
|
|