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

Side by Side Diff: appengine/auth_service/handlers_frontend.py

Issue 2840053003: auth_service: Fetch revisions of all configs (for UI) at once. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 # Copyright 2014 The LUCI Authors. All rights reserved. 1 # Copyright 2014 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 """This module defines Auth Server frontend url handlers.""" 5 """This module defines Auth Server frontend url handlers."""
6 6
7 import os 7 import os
8 import base64 8 import base64
9 9
10 import webapp2 10 import webapp2
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 class ServicesHandler(ui.UINavbarTabHandler): 64 class ServicesHandler(ui.UINavbarTabHandler):
65 """Page with management UI for linking services.""" 65 """Page with management UI for linking services."""
66 navbar_tab_url = '/auth/services' 66 navbar_tab_url = '/auth/services'
67 navbar_tab_id = 'services' 67 navbar_tab_id = 'services'
68 navbar_tab_title = 'Services' 68 navbar_tab_title = 'Services'
69 js_file_url = '/auth_service/static/js/services.js' 69 js_file_url = '/auth_service/static/js/services.js'
70 template_file = 'auth_service/services.html' 70 template_file = 'auth_service/services.html'
71 71
72 72
73 def get_additional_ui_environment(handler): 73 def get_additional_ui_data():
74 """Gets injected into Jinja and Javascript environment.""" 74 """Gets injected into Jinja and Javascript environment."""
75 # See config._CONFIG_SCHEMAS for where these paths are defined. 75 if not config.is_remote_configured():
76 if isinstance(handler, ConfigHandler): 76 return {'auth_service_config_locked': False}
77 path = 'imports.cfg' 77 config_revisions = {}
78 elif isinstance(handler, ui.IPWhitelistsHandler): 78 for path, rev in config.get_revisions().iteritems():
79 path = 'ip_whitelist.cfg' 79 config_revisions[path] = {
80 elif isinstance(handler, ui.OAuthConfigHandler): 80 'rev': rev.revision if rev else 'none',
81 path = 'oauth.cfg' 81 'url': rev.url if rev else 'about:blank',
82 else: 82 }
83 return {'auth_service_config_locked': config.is_remote_configured()}
84 rev = config.get_config_revision(path)
85 return { 83 return {
86 'auth_service_config_locked': config.is_remote_configured(), 84 'auth_service_config_locked': True,
87 'auth_service_config_remote_url': config.get_remote_url(), 85 'auth_service_config_remote_url': config.get_remote_url(),
88 'auth_service_config_rev': rev.revision if rev else 'none', 86 'auth_service_config_revisions': config_revisions,
nodir 2017/04/28 17:49:24 `auth_service_configs`? because there is URL and y
Vadim Sh. 2017/04/29 01:59:10 Done.
89 'auth_service_config_url': rev.url if rev else 'about:blank',
90 } 87 }
91 88
92 89
93 ################################################################################ 90 ################################################################################
94 ## API handlers. 91 ## API handlers.
95 92
96 93
97 class LinkTicketToken(auth.TokenKind): 94 class LinkTicketToken(auth.TokenKind):
98 """Parameters for ServiceLinkTicket.ticket token.""" 95 """Parameters for ServiceLinkTicket.ticket token."""
99 expiration_sec = 24 * 3600 96 expiration_sec = 24 * 3600
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 app_name='Auth Service', 430 app_name='Auth Service',
434 ui_tabs=[ 431 ui_tabs=[
435 ui.GroupsHandler, 432 ui.GroupsHandler,
436 ui.ChangeLogHandler, 433 ui.ChangeLogHandler,
437 ServicesHandler, 434 ServicesHandler,
438 ui.OAuthConfigHandler, 435 ui.OAuthConfigHandler,
439 ui.IPWhitelistsHandler, 436 ui.IPWhitelistsHandler,
440 ConfigHandler, 437 ConfigHandler,
441 ui.ApiDocHandler, 438 ui.ApiDocHandler,
442 ], 439 ],
443 env_callback=get_additional_ui_environment) 440 ui_data_callback=get_additional_ui_data)
444 template.bootstrap({'auth_service': TEMPLATES_DIR}) 441 template.bootstrap({'auth_service': TEMPLATES_DIR})
445 442
446 # Add a fake admin for local dev server. 443 # Add a fake admin for local dev server.
447 if utils.is_local_dev_server(): 444 if utils.is_local_dev_server():
448 auth.bootstrap_group( 445 auth.bootstrap_group(
449 auth.ADMIN_GROUP, 446 auth.ADMIN_GROUP,
450 [auth.Identity(auth.IDENTITY_USER, 'test@example.com')], 447 [auth.Identity(auth.IDENTITY_USER, 'test@example.com')],
451 'Users that can manage groups') 448 'Users that can manage groups')
452 return webapp2.WSGIApplication(get_routes(), debug=debug) 449 return webapp2.WSGIApplication(get_routes(), debug=debug)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698