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

Side by Side Diff: appengine/swarming/handlers_bot.py

Issue 2984843002: swarming: switch to a 'capability focused' ACL system (Closed)
Patch Set: Tuned permissions, added tests 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 | « no previous file | appengine/swarming/handlers_endpoints.py » ('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 """Internal bot API handlers.""" 5 """Internal bot API handlers."""
6 6
7 import base64 7 import base64
8 import json 8 import json
9 import logging 9 import logging
10 10
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 return existing_token 144 return existing_token
145 145
146 machine_type = None 146 machine_type = None
147 if bot_id: 147 if bot_id:
148 bot_info = bot_management.get_info_key(bot_id).get() 148 bot_info = bot_management.get_info_key(bot_id).get()
149 if bot_info: 149 if bot_info:
150 machine_type = bot_info.machine_type 150 machine_type = bot_info.machine_type
151 151
152 # TODO(vadimsh): Remove is_ip_whitelisted_machine check once all bots are 152 # TODO(vadimsh): Remove is_ip_whitelisted_machine check once all bots are
153 # using auth for bootstrap and updating. 153 # using auth for bootstrap and updating.
154 if (not acl.is_bootstrapper() and 154 if (not acl.can_create_bot() and
155 not acl.is_ip_whitelisted_machine() and 155 not acl.is_ip_whitelisted_machine() and
156 not (bot_id and bot_auth.is_authenticated_bot(bot_id, machine_type))): 156 not (bot_id and bot_auth.is_authenticated_bot(bot_id, machine_type))):
157 raise auth.AuthorizationError('Not allowed to access the bot code') 157 raise auth.AuthorizationError('Not allowed to access the bot code')
158 158
159 return bot_code.generate_bootstrap_token() if generate_token else None 159 return bot_code.generate_bootstrap_token() if generate_token else None
160 160
161 161
162 class BootstrapHandler(_BotAuthenticatingHandler): 162 class BootstrapHandler(_BotAuthenticatingHandler):
163 """Returns python code to run to bootstrap a swarming bot.""" 163 """Returns python code to run to bootstrap a swarming bot."""
164 164
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 ('/swarming/api/v1/bot/poll', BotPollHandler), 1045 ('/swarming/api/v1/bot/poll', BotPollHandler),
1046 ('/swarming/api/v1/bot/server_ping', ServerPingHandler), 1046 ('/swarming/api/v1/bot/server_ping', ServerPingHandler),
1047 ('/swarming/api/v1/bot/task_update', BotTaskUpdateHandler), 1047 ('/swarming/api/v1/bot/task_update', BotTaskUpdateHandler),
1048 ('/swarming/api/v1/bot/task_update/<task_id:[a-f0-9]+>', 1048 ('/swarming/api/v1/bot/task_update/<task_id:[a-f0-9]+>',
1049 BotTaskUpdateHandler), 1049 BotTaskUpdateHandler),
1050 ('/swarming/api/v1/bot/task_error', BotTaskErrorHandler), 1050 ('/swarming/api/v1/bot/task_error', BotTaskErrorHandler),
1051 ('/swarming/api/v1/bot/task_error/<task_id:[a-f0-9]+>', 1051 ('/swarming/api/v1/bot/task_error/<task_id:[a-f0-9]+>',
1052 BotTaskErrorHandler), 1052 BotTaskErrorHandler),
1053 ] 1053 ]
1054 return [webapp2.Route(*i) for i in routes] 1054 return [webapp2.Route(*i) for i in routes]
OLDNEW
« no previous file with comments | « no previous file | appengine/swarming/handlers_endpoints.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698