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

Side by Side Diff: scheduler/appengine/ui/common.go

Issue 2830443003: auth: Refactor how authentication methods are passed to server/auth library. (Closed)
Patch Set: fix test Created 3 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
« no previous file with comments | « scheduler/appengine/frontend/handler.go ('k') | server/auth/auth.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 // Package ui implements request handlers that serve user facing HTML pages. 5 // Package ui implements request handlers that serve user facing HTML pages.
6 package ui 6 package ui
7 7
8 import ( 8 import (
9 "strings" 9 "strings"
10 10
11 "golang.org/x/net/context" 11 "golang.org/x/net/context"
12 12
13 "github.com/luci/gae/service/info" 13 "github.com/luci/gae/service/info"
14 14
15 "github.com/luci/luci-go/appengine/gaeauth/server"
15 "github.com/luci/luci-go/server/auth" 16 "github.com/luci/luci-go/server/auth"
16 "github.com/luci/luci-go/server/auth/xsrf" 17 "github.com/luci/luci-go/server/auth/xsrf"
17 "github.com/luci/luci-go/server/router" 18 "github.com/luci/luci-go/server/router"
18 "github.com/luci/luci-go/server/templates" 19 "github.com/luci/luci-go/server/templates"
19 20
20 "github.com/luci/luci-go/scheduler/appengine/catalog" 21 "github.com/luci/luci-go/scheduler/appengine/catalog"
21 "github.com/luci/luci-go/scheduler/appengine/engine" 22 "github.com/luci/luci-go/scheduler/appengine/engine"
22 ) 23 )
23 24
24 // Config is global configuration of UI handlers. 25 // Config is global configuration of UI handlers.
25 type Config struct { 26 type Config struct {
26 Engine engine.Engine 27 Engine engine.Engine
27 Catalog catalog.Catalog 28 Catalog catalog.Catalog
28 TemplatesPath string // path to templates directory deployed to GAE 29 TemplatesPath string // path to templates directory deployed to GAE
29 } 30 }
30 31
31 // InstallHandlers adds HTTP handlers that render HTML pages. 32 // InstallHandlers adds HTTP handlers that render HTML pages.
32 func InstallHandlers(r *router.Router, base router.MiddlewareChain, cfg Config) { 33 func InstallHandlers(r *router.Router, base router.MiddlewareChain, cfg Config) {
33 tmpl := prepareTemplates(cfg.TemplatesPath) 34 tmpl := prepareTemplates(cfg.TemplatesPath)
34 35
35 m := base.Extend(func(c *router.Context, next router.Handler) { 36 m := base.Extend(func(c *router.Context, next router.Handler) {
36 c.Context = context.WithValue(c.Context, configContextKey(0), &c fg) 37 c.Context = context.WithValue(c.Context, configContextKey(0), &c fg)
37 next(c) 38 next(c)
38 » }, templates.WithTemplates(tmpl), auth.Authenticate) 39 » })
40 » m = m.Extend(
41 » » templates.WithTemplates(tmpl),
42 » » auth.Authenticate(server.CookieAuth),
43 » )
39 44
40 r.GET("/", m, indexPage) 45 r.GET("/", m, indexPage)
41 r.GET("/jobs/:ProjectID", m, projectPage) 46 r.GET("/jobs/:ProjectID", m, projectPage)
42 r.GET("/jobs/:ProjectID/:JobID", m, jobPage) 47 r.GET("/jobs/:ProjectID/:JobID", m, jobPage)
43 r.GET("/jobs/:ProjectID/:JobID/:InvID", m, invocationPage) 48 r.GET("/jobs/:ProjectID/:JobID/:InvID", m, invocationPage)
44 49
45 // All POST forms must be protected with XSRF token. 50 // All POST forms must be protected with XSRF token.
46 mxsrf := m.Extend(xsrf.WithTokenCheck) 51 mxsrf := m.Extend(xsrf.WithTokenCheck)
47 r.POST("/actions/runJob/:ProjectID/:JobID", mxsrf, runJobAction) 52 r.POST("/actions/runJob/:ProjectID/:JobID", mxsrf, runJobAction)
48 r.POST("/actions/pauseJob/:ProjectID/:JobID", mxsrf, pauseJobAction) 53 r.POST("/actions/pauseJob/:ProjectID/:JobID", mxsrf, pauseJobAction)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 "AppVersion": strings.Split(info.VersionID(c), ".")[0], 92 "AppVersion": strings.Split(info.VersionID(c), ".")[0],
88 "IsAnonymous": auth.CurrentIdentity(c) == "anony mous:anonymous", 93 "IsAnonymous": auth.CurrentIdentity(c) == "anony mous:anonymous",
89 "User": auth.CurrentUser(c), 94 "User": auth.CurrentUser(c),
90 "LoginURL": loginURL, 95 "LoginURL": loginURL,
91 "LogoutURL": logoutURL, 96 "LogoutURL": logoutURL,
92 "XsrfToken": token, 97 "XsrfToken": token,
93 }, nil 98 }, nil
94 }, 99 },
95 } 100 }
96 } 101 }
OLDNEW
« no previous file with comments | « scheduler/appengine/frontend/handler.go ('k') | server/auth/auth.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698