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

Side by Side 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: Code review comments, use Pub/Sub, archival staging, quality of life. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package admin 5 package admin
6 6
7 import ( 7 import (
8 "github.com/luci/gae/service/info"
9 "github.com/luci/luci-go/appengine/logdog/coordinator"
8 "github.com/luci/luci-go/common/api/logdog_coordinator/admin/v1" 10 "github.com/luci/luci-go/common/api/logdog_coordinator/admin/v1"
11 "github.com/luci/luci-go/common/grpcutil"
12 log "github.com/luci/luci-go/common/logging"
13 "github.com/luci/luci-go/server/auth"
14 "golang.org/x/net/context"
9 ) 15 )
10 16
11 // Server is the Cloud Endpoint service structure for the administrator endpoint . 17 // Server is the Cloud Endpoint service structure for the administrator endpoint .
12 type Server struct{} 18 type Server struct {
19 » coordinator.ServiceBase
20 }
13 21
14 var _ logdog.AdminServer = (*Server)(nil) 22 var _ logdog.AdminServer = (*Server)(nil)
23
24 // Auth returns an error if the current user does not have access to
25 // adminstrative endpoints.
26 func (*Server) Auth(c context.Context, svc coordinator.Services) error {
27 if err := coordinator.IsAdminUser(c, svc); err != nil {
28 log.WithError(err).Warningf(c, "User is not an administrator.")
29
30 // If we're on development server, any user can access this endp oint.
31 if info.Get(c).IsDevAppServer() {
32 log.Infof(c, "On development server, allowing admin acce ss.")
33 return nil
34 }
35
36 u := auth.CurrentUser(c)
37 if !(u != nil && u.Superuser) {
38 return grpcutil.PermissionDenied
39 }
40
41 log.Fields{
42 "email": u.Email,
43 "clientID": u.ClientID,
44 "name": u.Name,
45 }.Infof(c, "User is an AppEngine superuser. Granting access.")
46 return nil
47 }
48
49 return nil
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698