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

Side by Side Diff: appengine/gaemiddleware/auth.go

Issue 2588643002: Enable AppEngine profiling endpoints. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | appengine/gaemiddleware/routes.go » ('j') | appengine/gaemiddleware/routes.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package gaemiddleware
6
7 import (
8 "fmt"
9 "net/http"
10
11 "github.com/luci/luci-go/common/logging"
12 "github.com/luci/luci-go/server/auth"
13 "github.com/luci/luci-go/server/router"
14 )
15
16 // RequireSuperuser ensures that the request is from an authenticated AppEngine
17 // super user, as defined by the AppEngine instance.
18 //
19 // It is recommended that auth.Autologin be installed prior to calling this so
20 // that anonymous users have an opportunity to log in.
21 func RequireSuperuser(c *router.Context, next router.Handler) {
22 cu := auth.CurrentUser(c.Context)
23 if !cu.Superuser {
24 c.Writer.WriteHeader(http.StatusForbidden)
25 logging.Fields{
26 "user": cu.Identity,
27 }.Errorf(c.Context, "request not made by super user")
28 fmt.Fprint(c.Writer, "error: only available to super user")
29 return
30 }
31
32 next(c)
33 }
OLDNEW
« no previous file with comments | « no previous file | appengine/gaemiddleware/routes.go » ('j') | appengine/gaemiddleware/routes.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698