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

Side by Side Diff: appengine/gaeauth/server/default.go

Issue 1468053004: Add /auth/api/v1/server/info endpoints. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: fix typo Created 5 years, 1 month 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
« no previous file with comments | « no previous file | server/auth/info/info.go » ('j') | server/auth/info/info.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package server 5 package server
6 6
7 import ( 7 import (
8 "strings"
9
8 "github.com/julienschmidt/httprouter" 10 "github.com/julienschmidt/httprouter"
9 "golang.org/x/net/context" 11 "golang.org/x/net/context"
10 "google.golang.org/appengine" 12 "google.golang.org/appengine"
11 13
12 "github.com/luci/luci-go/server/auth" 14 "github.com/luci/luci-go/server/auth"
13 "github.com/luci/luci-go/server/auth/admin" 15 "github.com/luci/luci-go/server/auth/admin"
16 "github.com/luci/luci-go/server/auth/info"
14 "github.com/luci/luci-go/server/auth/openid" 17 "github.com/luci/luci-go/server/auth/openid"
15 "github.com/luci/luci-go/server/auth/signing" 18 "github.com/luci/luci-go/server/auth/signing"
16 "github.com/luci/luci-go/server/middleware" 19 "github.com/luci/luci-go/server/middleware"
17 20
18 "github.com/luci/luci-go/appengine/gaeauth/server/internal/authdb" 21 "github.com/luci/luci-go/appengine/gaeauth/server/internal/authdb"
19 ) 22 )
20 23
21 // CookieAuth is default cookie-based auth method to use on GAE. 24 // CookieAuth is default cookie-based auth method to use on GAE.
22 // 25 //
23 // 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
24 // OpenID. Works only if appropriate handlers have been installed into 27 // OpenID. Works only if appropriate handlers have been installed into
25 // the router. See InstallHandlers. 28 // the router. See InstallHandlers.
26 var CookieAuth auth.Method 29 var CookieAuth auth.Method
27 30
28 // InstallHandlers installs HTTP handlers for various routes related 31 // InstallHandlers installs HTTP handlers for various routes related
29 // to authentication system. 32 // to authentication system.
30 // 33 //
31 // Must be installed in server HTTP router for authentication to work. 34 // Must be installed in server HTTP router for authentication to work.
32 func InstallHandlers(r *httprouter.Router, base middleware.Base) { 35 func InstallHandlers(r *httprouter.Router, base middleware.Base) {
33 m := CookieAuth.(cookieAuthMethod) 36 m := CookieAuth.(cookieAuthMethod)
34 if oid, ok := m.Method.(*openid.AuthMethod); ok { 37 if oid, ok := m.Method.(*openid.AuthMethod); ok {
35 oid.InstallHandlers(r, base) 38 oid.InstallHandlers(r, base)
36 } 39 }
37 admin.InstallHandlers(r, base, &UsersAPIAuthMethod{}, adminPagesConfig{} ) 40 admin.InstallHandlers(r, base, &UsersAPIAuthMethod{}, adminPagesConfig{} )
38 auth.InstallHandlers(r, base) 41 auth.InstallHandlers(r, base)
39 authdb.InstallHandlers(r, base) 42 authdb.InstallHandlers(r, base)
43 info.InstallHandlers(r, base, getServiceInfo)
40 signing.InstallHandlers(r, base) 44 signing.InstallHandlers(r, base)
41 } 45 }
42 46
43 // Warmup prepares local caches. It's optional. 47 // Warmup prepares local caches. It's optional.
44 func Warmup(c context.Context) error { 48 func Warmup(c context.Context) error {
45 m := CookieAuth.(cookieAuthMethod) 49 m := CookieAuth.(cookieAuthMethod)
46 if oid, ok := m.Method.(*openid.AuthMethod); ok { 50 if oid, ok := m.Method.(*openid.AuthMethod); ok {
47 return oid.Warmup(c) 51 return oid.Warmup(c)
48 } 52 }
49 return nil 53 return nil
50 } 54 }
51 55
56 func getServiceInfo(c context.Context) (info.ServiceInfo, error) {
57 account, err := appengine.ServiceAccount(c)
58 if err != nil {
59 return info.ServiceInfo{}, err
60 }
61 return info.ServiceInfo{
62 AppID: appengine.AppID(c),
63 AppRuntime: "go",
M-A Ruel 2015/11/24 13:47:59 Do you think it's useful to have runtime version?
Vadim Sh. 2015/11/24 19:27:29 Done.
64 AppVersion: strings.Split(appengine.VersionID(c), ".")[0 ],
65 ServiceAccountName: account,
66 }, nil
67 }
68
52 /// 69 ///
53 70
54 // adminPagesConfig is used by server/auth/admin to display admin UI 71 // adminPagesConfig is used by server/auth/admin to display admin UI
55 type adminPagesConfig struct{} 72 type adminPagesConfig struct{}
56 73
57 func (adminPagesConfig) GetAppServiceAccount(c context.Context) (string, error) { 74 func (adminPagesConfig) GetAppServiceAccount(c context.Context) (string, error) {
58 return appengine.ServiceAccount(c) 75 return appengine.ServiceAccount(c)
59 } 76 }
60 77
61 func (adminPagesConfig) GetReplicationState(c context.Context) (string, int64, e rror) { 78 func (adminPagesConfig) GetReplicationState(c context.Context) (string, int64, e rror) {
(...skipping 29 matching lines...) Expand all
91 CookieAuth = cookieAuthMethod{UsersAPIAuthMethod{}} 108 CookieAuth = cookieAuthMethod{UsersAPIAuthMethod{}}
92 } else { 109 } else {
93 CookieAuth = cookieAuthMethod{ 110 CookieAuth = cookieAuthMethod{
94 &openid.AuthMethod{ 111 &openid.AuthMethod{
95 SessionStore: &SessionStore{Namespace: "o penid"}, 112 SessionStore: &SessionStore{Namespace: "o penid"},
96 IncompatibleCookies: []string{"SACSID", "dev_app server_login"}, 113 IncompatibleCookies: []string{"SACSID", "dev_app server_login"},
97 }, 114 },
98 } 115 }
99 } 116 }
100 } 117 }
OLDNEW
« no previous file with comments | « no previous file | server/auth/info/info.go » ('j') | server/auth/info/info.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698