Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2027)

Unified Diff: appengine/logdog/coordinator/endpoints/admin/service.go

Issue 1863973002: LogDog: Update to archival V2. (Closed) Base URL: https://github.com/luci/luci-go@grpcutil-errors
Patch Set: Fix proto comment. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/logdog/coordinator/endpoints/admin/service.go
diff --git a/appengine/logdog/coordinator/endpoints/admin/service.go b/appengine/logdog/coordinator/endpoints/admin/service.go
index 7d0382545b173a2ccc175025ac8dcc2940b10c60..0cb2bcea8be01b2a3bd7d110e25d51e12cffb015 100644
--- a/appengine/logdog/coordinator/endpoints/admin/service.go
+++ b/appengine/logdog/coordinator/endpoints/admin/service.go
@@ -5,10 +5,46 @@
package admin
import (
+ "github.com/luci/gae/service/info"
+ "github.com/luci/luci-go/appengine/logdog/coordinator"
"github.com/luci/luci-go/common/api/logdog_coordinator/admin/v1"
+ "github.com/luci/luci-go/common/grpcutil"
+ log "github.com/luci/luci-go/common/logging"
+ "github.com/luci/luci-go/server/auth"
+ "golang.org/x/net/context"
)
// Server is the Cloud Endpoint service structure for the administrator endpoint.
-type Server struct{}
+type Server struct {
+ coordinator.ServiceBase
+}
var _ logdog.AdminServer = (*Server)(nil)
+
+// Auth returns an error if the current user does not have access to
+// adminstrative endpoints.
+func (*Server) Auth(c context.Context, svc coordinator.Services) error {
+ if err := coordinator.IsAdminUser(c, svc); err != nil {
+ log.WithError(err).Warningf(c, "User is not an administrator.")
+
+ // If we're on development server, any user can access this endpoint.
+ if info.Get(c).IsDevAppServer() {
+ log.Infof(c, "On development server, allowing admin access.")
+ return nil
+ }
+
+ u := auth.CurrentUser(c)
+ if !(u != nil && u.Superuser) {
+ return grpcutil.PermissionDenied
+ }
+
+ log.Fields{
+ "email": u.Email,
+ "clientID": u.ClientID,
+ "name": u.Name,
+ }.Infof(c, "User is an AppEngine superuser. Granting access.")
+ return nil
+ }
+
+ return nil
+}
« no previous file with comments | « appengine/logdog/coordinator/coordinatorTest/service.go ('k') | appengine/logdog/coordinator/endpoints/admin/setConfig.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698