| OLD | NEW |
| 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 main | 5 package main |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "net/http" | 8 "net/http" |
| 9 | 9 |
| 10 "github.com/julienschmidt/httprouter" | 10 "github.com/julienschmidt/httprouter" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // Redirect "/" to "/app/". | 58 // Redirect "/" to "/app/". |
| 59 router.GET("/", func(w http.ResponseWriter, r *http.Request, ps httprout
er.Params) { | 59 router.GET("/", func(w http.ResponseWriter, r *http.Request, ps httprout
er.Params) { |
| 60 http.Redirect(w, r, "/app/", http.StatusFound) | 60 http.Redirect(w, r, "/app/", http.StatusFound) |
| 61 }) | 61 }) |
| 62 | 62 |
| 63 http.Handle("/", router) | 63 http.Handle("/", router) |
| 64 appengine.Main() | 64 appengine.Main() |
| 65 } | 65 } |
| 66 | 66 |
| 67 func accessControl(c context.Context, origin string) bool { | 67 func accessControl(c context.Context, origin string) bool { |
| 68 » cfg, err := config.Load(c) | 68 » gcfg, err := config.LoadGlobalConfig(c) |
| 69 if err != nil { | 69 if err != nil { |
| 70 » » log.WithError(err).Errorf(c, "Failed to get config for access co
ntrol check.") | 70 » » log.WithError(err).Errorf(c, "Failed to get global config for ac
cess control check.") |
| 71 return false | 71 return false |
| 72 } | 72 } |
| 73 | 73 |
| 74 cfg, err := gcfg.LoadConfig(c) |
| 75 if err != nil { |
| 76 log.WithError(err).Errorf(c, "Failed to get application config f
or access control check.") |
| 77 return false |
| 78 } |
| 79 |
| 74 ccfg := cfg.GetCoordinator() | 80 ccfg := cfg.GetCoordinator() |
| 75 if ccfg == nil { | 81 if ccfg == nil { |
| 76 return false | 82 return false |
| 77 } | 83 } |
| 78 | 84 |
| 79 for _, o := range ccfg.RpcAllowOrigins { | 85 for _, o := range ccfg.RpcAllowOrigins { |
| 80 if o == origin { | 86 if o == origin { |
| 81 return true | 87 return true |
| 82 } | 88 } |
| 83 } | 89 } |
| 84 return false | 90 return false |
| 85 } | 91 } |
| OLD | NEW |