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

Side by Side Diff: examples/appengine/helloworld_flexible/frontend/main.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
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 main implements HTTP server that handles requests to default 5 // Package main implements HTTP server that handles requests to default
6 // module. 6 // module.
7 package main 7 package main
8 8
9 import ( 9 import (
10 "net/http" 10 "net/http"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 "IsAdmin": isAdmin, 45 "IsAdmin": isAdmin,
46 "User": auth.CurrentUser(c), 46 "User": auth.CurrentUser(c),
47 "LoginURL": loginURL, 47 "LoginURL": loginURL,
48 "LogoutURL": logoutURL, 48 "LogoutURL": logoutURL,
49 }, nil 49 }, nil
50 }, 50 },
51 } 51 }
52 52
53 // base returns the root middleware chain. 53 // base returns the root middleware chain.
54 func base() router.MiddlewareChain { 54 func base() router.MiddlewareChain {
55 methods := auth.Authenticator{
56 &server.OAuth2Method{Scopes: []string{server.EmailScope}},
57 server.CookieAuth,
58 &server.InboundAppIDAuthMethod{},
59 }
60 return gaemiddleware.BaseProd().Extend( 55 return gaemiddleware.BaseProd().Extend(
61 templates.WithTemplates(templateBundle), 56 templates.WithTemplates(templateBundle),
62 » » auth.Use(methods), 57 » » auth.Authenticate(server.CookieAuth),
63 » » auth.Authenticate,
64 ) 58 )
65 } 59 }
66 60
67 //// Routes. 61 //// Routes.
68 62
69 func main() { 63 func main() {
70 r := router.New() 64 r := router.New()
71 65
72 gaemiddleware.InstallHandlers(r) 66 gaemiddleware.InstallHandlers(r)
73 r.GET("/", base(), indexPage) 67 r.GET("/", base(), indexPage)
74 http.DefaultServeMux.Handle("/", r) 68 http.DefaultServeMux.Handle("/", r)
75 69
76 appengine.Main() 70 appengine.Main()
77 } 71 }
78 72
79 //// Handlers. 73 //// Handlers.
80 74
81 func indexPage(c *router.Context) { 75 func indexPage(c *router.Context) {
82 templates.MustRender(c.Context, c.Writer, "pages/index.html", nil) 76 templates.MustRender(c.Context, c.Writer, "pages/index.html", nil)
83 } 77 }
OLDNEW
« no previous file with comments | « appengine/gaeauth/server/prpc.go ('k') | examples/appengine/helloworld_standard/frontend/handler.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698