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

Unified Diff: appengine/chromium_build_stats/default/compiler_proxy_log.go

Issue 2125513002: chromium_build_stats: redirect login url if not logged in. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/chromium_build_stats/default/auth.go ('k') | appengine/chromium_build_stats/default/ninja_log.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/chromium_build_stats/default/compiler_proxy_log.go
diff --git a/appengine/chromium_build_stats/default/compiler_proxy_log.go b/appengine/chromium_build_stats/default/compiler_proxy_log.go
index ea81829173feb8b44593571188a957affbb38bcc..6845057fca41ba70d970cc1134d99d305db468a6 100644
--- a/appengine/chromium_build_stats/default/compiler_proxy_log.go
+++ b/appengine/chromium_build_stats/default/compiler_proxy_log.go
@@ -86,6 +86,23 @@ var (
</body>
</html>
`))
+
+ compilerProxyAuthTmpl = template.Must(template.New("compiler_proxy_auth").Parse(`
+<html>
+<head>
+ <title>compiler_proxy log</title>
+</head>
+<body>
+{{if .User}}
+{{.User.Email}} is not alow to access this page.
+Please <a href="{{.Logout}}">logout</a> and login with @google.com account.
+<div align="right"><a href="{{.Logout}}">logout</a></div>
+{{else}}
+ <div align="right"><a href="{{.Login}}">login</a></div>
+You need to <a href="{{.Login}}">login</a> with @google.com account to access compiler_proxy log file.
+{{end}}
+</body>
+</html>`))
)
func init() {
@@ -95,13 +112,13 @@ func init() {
// compilerProxyLogHandler handles /<path> for compiler_proxy.INFO log file in gs://chrome-goma-log/<path>
func compilerProxyLogHandler(w http.ResponseWriter, req *http.Request) {
ctx := appengine.NewContext(req)
- user := user.Current(ctx)
- if user == nil {
- http.Error(w, "Login required", http.StatusUnauthorized)
+ u := user.Current(ctx)
+ if u == nil {
+ authPage(w, req, http.StatusUnauthorized, compilerProxyAuthTmpl, u, path.Join("/compiler_proxy_log", req.URL.Path))
return
}
- if !strings.HasSuffix(user.Email, "@google.com") {
- http.Error(w, "Unauthorized to access", http.StatusUnauthorized)
+ if !strings.HasSuffix(u.Email, "@google.com") {
Yoshisato Yanagisawa 2016/07/05 05:00:05 maybe intended but L117 and L120 are the same?
+ authPage(w, req, http.StatusUnauthorized, compilerProxyAuthTmpl, u, path.Join("/compiler_proxy_log", req.URL.Path))
return
}
« no previous file with comments | « appengine/chromium_build_stats/default/auth.go ('k') | appengine/chromium_build_stats/default/ninja_log.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698