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

Side by Side Diff: appengine/config_service/handlers.py

Issue 2962703003: config_service: Add authentication to the UI. (Closed)
Patch Set: Added TODO to handlers.py and confirmed versions in bower.json Created 3 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 unified diff | Download patch
« no previous file with comments | « appengine/config_service/app.yaml ('k') | appengine/config_service/ui/README.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import httplib 5 import httplib
6 6
7 import webapp2 7 import webapp2
8 8
9 from components import decorators 9 from components import decorators
10 from components.config.proto import service_config_pb2 10 from components.config.proto import service_config_pb2
11 from google.appengine.ext.webapp import template
11 12
12 import common 13 import common
13 import gitiles_import 14 import gitiles_import
14 import notifications 15 import notifications
16 import os
15 import storage 17 import storage
16 18
17 19
18 class CronGitilesImport(webapp2.RequestHandler): 20 class CronGitilesImport(webapp2.RequestHandler):
19 """Imports configs from Gitiles.""" 21 """Imports configs from Gitiles."""
20 @decorators.require_cronjob 22 @decorators.require_cronjob
21 def get(self): 23 def get(self):
22 gitiles_import.cron_run_import() 24 gitiles_import.cron_run_import()
23 25
24 26
25 class MainPageHandler(webapp2.RequestHandler): 27 class MainPageHandler(webapp2.RequestHandler):
26 """Redirects to API Explorer.""" 28 """Redirects to API Explorer."""
27 29
28 def get(self): 30 def get(self):
29 self.redirect('_ah/api/explorer') 31 self.redirect('_ah/api/explorer')
30 32
33 class UIHandler(webapp2.RequestHandler):
34 """ Serves the UI with the proper client ID. """
35
36 def get(self):
37 # TODO(cwpayton): put the client_id in a proto file so that it is
38 # configurable and can be read dynamically by this file.
39 template_values = {
40 'client_id':
41 '247108661754-svmo17vmk1j5hlt388gb45qblgvg2h98.apps.googleusercontent. com'
42 }
43 path = os.path.join(os.path.dirname(__file__), 'ui/static/index.html')
44 self.response.out.write(template.render(path, template_values))
45
31 46
32 class SchemasHandler(webapp2.RequestHandler): 47 class SchemasHandler(webapp2.RequestHandler):
33 """Redirects to a known schema definition.""" 48 """Redirects to a known schema definition."""
34 49
35 def get(self, name): 50 def get(self, name):
36 cfg = storage.get_self_config_async( 51 cfg = storage.get_self_config_async(
37 common.SCHEMAS_FILENAME, service_config_pb2.SchemasCfg).get_result() 52 common.SCHEMAS_FILENAME, service_config_pb2.SchemasCfg).get_result()
38 # Assume cfg was validated by validation.py 53 # Assume cfg was validated by validation.py
39 if cfg: 54 if cfg:
40 for schema in cfg.schemas: 55 for schema in cfg.schemas:
41 if schema.name == name: 56 if schema.name == name:
42 # Convert from unicode. 57 # Convert from unicode.
43 assert schema.url 58 assert schema.url
44 self.redirect(str(schema.url)) 59 self.redirect(str(schema.url))
45 return 60 return
46 61
47 self.response.write('Schema %s not found\n' % name) 62 self.response.write('Schema %s not found\n' % name)
48 self.response.set_status(httplib.NOT_FOUND) 63 self.response.set_status(httplib.NOT_FOUND)
49 64
50 65
51 def get_frontend_routes(): # pragma: no cover 66 def get_frontend_routes(): # pragma: no cover
52 return [ 67 return [
53 webapp2.Route(r'/', MainPageHandler), 68 webapp2.Route(r'/', MainPageHandler),
69 webapp2.Route(r'/newui', UIHandler),
54 webapp2.Route(r'/schemas/<name:.+>', SchemasHandler), 70 webapp2.Route(r'/schemas/<name:.+>', SchemasHandler),
55 webapp2.Route(r'/_ah/bounce', notifications.BounceHandler), 71 webapp2.Route(r'/_ah/bounce', notifications.BounceHandler),
56 ] 72 ]
57 73
58 74
59 def get_backend_routes(): # pragma: no cover 75 def get_backend_routes(): # pragma: no cover
60 return [ 76 return [
61 webapp2.Route( 77 webapp2.Route(
62 r'/internal/cron/luci-config/gitiles_import', 78 r'/internal/cron/luci-config/gitiles_import',
63 CronGitilesImport), 79 CronGitilesImport),
64 ] 80 ]
OLDNEW
« no previous file with comments | « appengine/config_service/app.yaml ('k') | appengine/config_service/ui/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698