OLD | NEW |
---|---|
1 # Copyright 2012 The Swarming Authors. All rights reserved. | 1 # Copyright 2012 The Swarming Authors. All rights reserved. |
2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed by the Apache v2.0 license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """This module defines Isolate Server frontend url handlers.""" | 5 """This module defines Isolate Server frontend url handlers.""" |
6 | 6 |
7 import datetime | 7 import datetime |
8 import json | 8 import json |
9 | 9 |
10 import webapp2 | 10 import webapp2 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 | 55 |
56 | 56 |
57 ### Restricted handlers | 57 ### Restricted handlers |
58 | 58 |
59 | 59 |
60 class RestrictedConfigHandler(auth.AuthenticatingHandler): | 60 class RestrictedConfigHandler(auth.AuthenticatingHandler): |
61 @auth.autologin | 61 @auth.autologin |
62 @auth.require(auth.is_admin) | 62 @auth.require(auth.is_admin) |
63 def get(self): | 63 def get(self): |
64 self.common(None) | 64 self.common(None) |
65 | 65 |
M-A Ruel
2016/02/19 02:44:40
you can add the function here as a @staticmethod,
Sergey Berezin
2016/02/19 20:46:51
Done.
| |
66 @auth.require(auth.is_admin) | 66 @auth.require(auth.is_admin) |
67 def post(self): | 67 def post(self): |
68 # Convert MultiDict into a dict. | 68 # Convert MultiDict into a dict. |
69 params = { | 69 params = { |
70 k: self.request.params.getone(k) for k in self.request.params | 70 k: config.GlobalConfig.cast_to_type(k, self.request.params.getone(k)) |
71 for k in self.request.params | |
71 if k not in ('keyid', 'xsrf_token') | 72 if k not in ('keyid', 'xsrf_token') |
72 } | 73 } |
73 cfg = config.settings(fresh=True) | 74 cfg = config.settings(fresh=True) |
74 keyid = int(self.request.get('keyid', '0')) | 75 keyid = int(self.request.get('keyid', '0')) |
75 if cfg.key.integer_id() != keyid: | 76 if cfg.key.integer_id() != keyid: |
76 self.common('Update conflict %s != %s' % (cfg.key.integer_id(), keyid)) | 77 self.common('Update conflict %s != %s' % (cfg.key.integer_id(), keyid)) |
77 return | 78 return |
78 params['default_expiration'] = int(params['default_expiration']) | 79 params['default_expiration'] = int(params['default_expiration']) |
79 cfg.populate(**params) | 80 cfg.populate(**params) |
80 try: | 81 try: |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 def create_application(debug): | 301 def create_application(debug): |
301 """Creates the url router. | 302 """Creates the url router. |
302 | 303 |
303 The basic layouts is as follow: | 304 The basic layouts is as follow: |
304 - /restricted/.* requires being an instance administrator. | 305 - /restricted/.* requires being an instance administrator. |
305 - /stats/.* has statistics. | 306 - /stats/.* has statistics. |
306 """ | 307 """ |
307 acl.bootstrap() | 308 acl.bootstrap() |
308 template.bootstrap() | 309 template.bootstrap() |
309 return webapp2.WSGIApplication(get_routes(), debug=debug) | 310 return webapp2.WSGIApplication(get_routes(), debug=debug) |
OLD | NEW |