| 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 frontend implements HTTP server that handles requests to default | 5 // Package frontend implements HTTP server that handles requests to default |
| 6 // module. | 6 // module. |
| 7 package frontend | 7 package frontend |
| 8 | 8 |
| 9 import ( | 9 import ( |
| 10 "net/http" | 10 "net/http" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 "LoginURL": loginURL, | 50 "LoginURL": loginURL, |
| 51 "LogoutURL": logoutURL, | 51 "LogoutURL": logoutURL, |
| 52 }, nil | 52 }, nil |
| 53 }, | 53 }, |
| 54 } | 54 } |
| 55 | 55 |
| 56 // pageBase returns the middleware chain for page handlers. | 56 // pageBase returns the middleware chain for page handlers. |
| 57 func pageBase() router.MiddlewareChain { | 57 func pageBase() router.MiddlewareChain { |
| 58 return gaemiddleware.BaseProd().Extend( | 58 return gaemiddleware.BaseProd().Extend( |
| 59 templates.WithTemplates(templateBundle), | 59 templates.WithTemplates(templateBundle), |
| 60 » » auth.Use(auth.Authenticator{server.CookieAuth}), | 60 » » auth.Authenticate(server.CookieAuth), |
| 61 » » auth.Authenticate, | |
| 62 ) | 61 ) |
| 63 } | 62 } |
| 64 | 63 |
| 65 // prpcBase returns the middleware chain for pRPC API handlers. | 64 // prpcBase returns the middleware chain for pRPC API handlers. |
| 66 func prpcBase() router.MiddlewareChain { | 65 func prpcBase() router.MiddlewareChain { |
| 67 // OAuth 2.0 with email scope is registered as a default authenticator | 66 // OAuth 2.0 with email scope is registered as a default authenticator |
| 68 // by importing "github.com/luci/luci-go/appengine/gaeauth/server". | 67 // by importing "github.com/luci/luci-go/appengine/gaeauth/server". |
| 69 // No need to setup an authenticator here. | 68 // No need to setup an authenticator here. |
| 70 // | 69 // |
| 71 // For authorization checks, we use per-service decorators; see | 70 // For authorization checks, we use per-service decorators; see |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 api.InstallHandlers(r, prpcBase()) | 106 api.InstallHandlers(r, prpcBase()) |
| 108 | 107 |
| 109 http.DefaultServeMux.Handle("/", r) | 108 http.DefaultServeMux.Handle("/", r) |
| 110 } | 109 } |
| 111 | 110 |
| 112 //// Handlers. | 111 //// Handlers. |
| 113 | 112 |
| 114 func indexPage(c *router.Context) { | 113 func indexPage(c *router.Context) { |
| 115 templates.MustRender(c.Context, c.Writer, "pages/index.html", nil) | 114 templates.MustRender(c.Context, c.Writer, "pages/index.html", nil) |
| 116 } | 115 } |
| OLD | NEW |