| 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 server | 5 package server |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "runtime" | 8 "runtime" |
| 9 "strings" | 9 "strings" |
| 10 | 10 |
| 11 "github.com/julienschmidt/httprouter" | |
| 12 "golang.org/x/net/context" | 11 "golang.org/x/net/context" |
| 13 "google.golang.org/appengine" | 12 "google.golang.org/appengine" |
| 14 | 13 |
| 15 gae_info "github.com/luci/gae/service/info" | 14 gae_info "github.com/luci/gae/service/info" |
| 16 "github.com/luci/luci-go/server/auth" | 15 "github.com/luci/luci-go/server/auth" |
| 17 "github.com/luci/luci-go/server/auth/info" | 16 "github.com/luci/luci-go/server/auth/info" |
| 18 "github.com/luci/luci-go/server/auth/openid" | 17 "github.com/luci/luci-go/server/auth/openid" |
| 19 "github.com/luci/luci-go/server/auth/signing" | 18 "github.com/luci/luci-go/server/auth/signing" |
| 20 » "github.com/luci/luci-go/server/middleware" | 19 » "github.com/luci/luci-go/server/router" |
| 21 | 20 |
| 22 "github.com/luci/luci-go/appengine/gaeauth/server/internal/authdb" | 21 "github.com/luci/luci-go/appengine/gaeauth/server/internal/authdb" |
| 23 ) | 22 ) |
| 24 | 23 |
| 25 // CookieAuth is default cookie-based auth method to use on GAE. | 24 // CookieAuth is default cookie-based auth method to use on GAE. |
| 26 // | 25 // |
| 27 // On dev server it is based on dev server cookies, in prod it is based on | 26 // On dev server it is based on dev server cookies, in prod it is based on |
| 28 // OpenID. Works only if appropriate handlers have been installed into | 27 // OpenID. Works only if appropriate handlers have been installed into |
| 29 // the router. See InstallHandlers. | 28 // the router. See InstallHandlers. |
| 30 var CookieAuth auth.Method | 29 var CookieAuth auth.Method |
| 31 | 30 |
| 32 // InstallWebHandlers installs HTTP handlers for various default routes related | 31 // InstallHandlers installs HTTP handlers for various default routes related |
| 33 // to authentication system. | 32 // to authentication system. |
| 34 // | 33 // |
| 35 // Must be installed in server HTTP router for authentication to work. | 34 // Must be installed in server HTTP router for authentication to work. |
| 36 // | 35 func InstallHandlers(r *router.Router, base router.MiddlewareChain) { |
| 37 // TODO(vadimsh): Rename to InstallHandlers after June 1 2016. It was renamed | |
| 38 // to purposely break code that called it (since its semantics has changed). | |
| 39 func InstallWebHandlers(r *httprouter.Router, base middleware.Base) { | |
| 40 m := CookieAuth.(cookieAuthMethod) | 36 m := CookieAuth.(cookieAuthMethod) |
| 41 if oid, ok := m.Method.(*openid.AuthMethod); ok { | 37 if oid, ok := m.Method.(*openid.AuthMethod); ok { |
| 42 oid.InstallHandlers(r, base) | 38 oid.InstallHandlers(r, base) |
| 43 } | 39 } |
| 44 auth.InstallHandlers(r, base) | 40 auth.InstallHandlers(r, base) |
| 45 authdb.InstallHandlers(r, base) | 41 authdb.InstallHandlers(r, base) |
| 46 info.InstallHandlers(r, base, getServiceInfo) | 42 info.InstallHandlers(r, base, getServiceInfo) |
| 47 signing.InstallHandlers(r, base) | 43 signing.InstallHandlers(r, base) |
| 48 } | 44 } |
| 49 | 45 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 CookieAuth = cookieAuthMethod{UsersAPIAuthMethod{}} | 89 CookieAuth = cookieAuthMethod{UsersAPIAuthMethod{}} |
| 94 } else { | 90 } else { |
| 95 CookieAuth = cookieAuthMethod{ | 91 CookieAuth = cookieAuthMethod{ |
| 96 &openid.AuthMethod{ | 92 &openid.AuthMethod{ |
| 97 SessionStore: &SessionStore{Prefix: "open
id"}, | 93 SessionStore: &SessionStore{Prefix: "open
id"}, |
| 98 IncompatibleCookies: []string{"SACSID", "dev_app
server_login"}, | 94 IncompatibleCookies: []string{"SACSID", "dev_app
server_login"}, |
| 99 }, | 95 }, |
| 100 } | 96 } |
| 101 } | 97 } |
| 102 } | 98 } |
| OLD | NEW |