| OLD | NEW |
| 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 services | 5 package services |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 » "github.com/luci/luci-go/appengine/logdog/coordinator/config" | 8 » "github.com/luci/luci-go/appengine/logdog/coordinator" |
| 9 "github.com/luci/luci-go/common/api/logdog_coordinator/services/v1" | 9 "github.com/luci/luci-go/common/api/logdog_coordinator/services/v1" |
| 10 "github.com/luci/luci-go/common/grpcutil" | 10 "github.com/luci/luci-go/common/grpcutil" |
| 11 log "github.com/luci/luci-go/common/logging" | 11 log "github.com/luci/luci-go/common/logging" |
| 12 "golang.org/x/net/context" | 12 "golang.org/x/net/context" |
| 13 ) | 13 ) |
| 14 | 14 |
| 15 // Server is a Cloud Endpoint service supporting privileged support services. |
| 16 // |
| 17 // This endpoint is restricted to LogDog support service accounts. |
| 18 type Server struct { |
| 19 coordinator.ServiceBase |
| 20 } |
| 21 |
| 22 var _ logdog.ServicesServer = (*Server)(nil) |
| 23 |
| 15 // Auth is endpoint middleware that asserts that the current user is a member of | 24 // Auth is endpoint middleware that asserts that the current user is a member of |
| 16 // the configured group. | 25 // the configured group. |
| 17 func Auth(c context.Context) error { | 26 func Auth(c context.Context, svc coordinator.Services) error { |
| 18 » if err := config.IsServiceUser(c); err != nil { | 27 » if err := coordinator.IsServiceUser(c, svc); err != nil { |
| 19 log.Fields{ | 28 log.Fields{ |
| 20 log.ErrorKey: err, | 29 log.ErrorKey: err, |
| 21 }.Errorf(c, "Failed to authenticate user as a service.") | 30 }.Errorf(c, "Failed to authenticate user as a service.") |
| 22 » » if !config.IsMembershipError(err) { | 31 » » if !coordinator.IsMembershipError(err) { |
| 23 // Not a membership error. Something went wrong on the s
erver's end. | 32 // Not a membership error. Something went wrong on the s
erver's end. |
| 24 return grpcutil.Internal | 33 return grpcutil.Internal |
| 25 } | 34 } |
| 26 return grpcutil.PermissionDenied | 35 return grpcutil.PermissionDenied |
| 27 } | 36 } |
| 28 return nil | 37 return nil |
| 29 } | 38 } |
| 30 | |
| 31 // Server is a Cloud Endpoint service supporting privileged support services. | |
| 32 // | |
| 33 // This endpoint is restricted to LogDog support service accounts. | |
| 34 type Server struct{} | |
| 35 | |
| 36 var _ logdog.ServicesServer = (*Server)(nil) | |
| OLD | NEW |