Chromium Code Reviews| Index: milo/appengine/buildbot/master.go |
| diff --git a/milo/appengine/buildbot/master.go b/milo/appengine/buildbot/master.go |
| index 6fcef9219291e4fa81ae5969f850fc238d3dc4a9..7fe602b56455ba6eafed04670f9503a78391361d 100644 |
| --- a/milo/appengine/buildbot/master.go |
| +++ b/milo/appengine/buildbot/master.go |
| @@ -16,6 +16,8 @@ import ( |
| "github.com/luci/luci-go/common/logging" |
| "github.com/luci/luci-go/milo/api/resp" |
| "github.com/luci/luci-go/milo/appengine/settings" |
| + "github.com/luci/luci-go/server/auth" |
| + "github.com/luci/luci-go/server/auth/identity" |
| "golang.org/x/net/context" |
| ) |
| @@ -36,12 +38,26 @@ func decodeMasterEntry( |
| // getMasterEntry feches the named master and does an ACL check on the |
| // current user. |
| +// It returns: |
| +// 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 getMasterEntry(c context.Context, name string) (*buildbotMasterEntry, error) { |
| entry := buildbotMasterEntry{Name: name} |
| err := ds.Get(c, &entry) |
| + cu := auth.CurrentUser(c) |
| + |
| switch { |
| case err == ds.ErrNoSuchEntity: |
| - return nil, errMasterNotFound |
| + if cu.Identity == identity.AnonymousIdentity { |
|
estaab
2016/12/01 00:04:34
It seems pretty dangerous to have the auth checkin
hinoka
2016/12/01 02:08:54
Done.
|
| + return nil, errNotAuth |
| + } else { |
| + return nil, errMasterNotFound |
| + } |
| case err != nil: |
| logging.WithError(err).Errorf( |
| c, "Encountered error while fetching entry for %s:\n%s", name, err) |
| @@ -55,7 +71,11 @@ func getMasterEntry(c context.Context, name string) (*buildbotMasterEntry, error |
| return nil, err |
| } |
| if !allowed { |
| - return nil, errMasterNotFound |
| + if cu.Identity == identity.AnonymousIdentity { |
| + return nil, errNotAuth |
| + } else { |
| + return nil, errMasterNotFound |
| + } |
| } |
| } |