| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |