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

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: 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(&auth.Authenticator{
63 » » auth.Authenticate, 58 » » » Methods: []auth.Method{
59 » » » » &server.OAuth2Method{Scopes: []string{server.Ema ilScope}},
60 » » » » server.CookieAuth,
61 » » » » &server.InboundAppIDAuthMethod{},
62 » » » },
63 » » }),
64 ) 64 )
65 } 65 }
66 66
67 //// Routes. 67 //// Routes.
68 68
69 func main() { 69 func main() {
70 r := router.New() 70 r := router.New()
71 71
72 gaemiddleware.InstallHandlers(r) 72 gaemiddleware.InstallHandlers(r)
73 r.GET("/", base(), indexPage) 73 r.GET("/", base(), indexPage)
74 http.DefaultServeMux.Handle("/", r) 74 http.DefaultServeMux.Handle("/", r)
75 75
76 appengine.Main() 76 appengine.Main()
77 } 77 }
78 78
79 //// Handlers. 79 //// Handlers.
80 80
81 func indexPage(c *router.Context) { 81 func indexPage(c *router.Context) {
82 templates.MustRender(c.Context, c.Writer, "pages/index.html", nil) 82 templates.MustRender(c.Context, c.Writer, "pages/index.html", nil)
83 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698