| OLD | NEW |
| 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 """Defines access groups.""" | 5 """Defines access groups.""" |
| 6 | 6 |
| 7 from components import auth | 7 from components import auth |
| 8 from components import utils | 8 from components import utils |
| 9 | 9 |
| 10 from server import bot_auth | 10 from server import bot_auth |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 | 58 |
| 59 def get_user_type(): | 59 def get_user_type(): |
| 60 """Returns a string describing the current access control for the user.""" | 60 """Returns a string describing the current access control for the user.""" |
| 61 if is_admin(): | 61 if is_admin(): |
| 62 return 'admin' | 62 return 'admin' |
| 63 if is_privileged_user(): | 63 if is_privileged_user(): |
| 64 return 'privileged user' | 64 return 'privileged user' |
| 65 if is_user(): | 65 if is_user(): |
| 66 return 'user' | 66 return 'user' |
| 67 return 'unknown user' | |
| 68 | 67 |
| 69 | 68 |
| 70 def bootstrap_dev_server_acls(): | 69 def bootstrap_dev_server_acls(): |
| 71 """Adds localhost to IP whitelist and Swarming groups.""" | 70 """Adds localhost to IP whitelist and Swarming groups.""" |
| 72 assert utils.is_local_dev_server() | 71 assert utils.is_local_dev_server() |
| 73 if auth.is_replica(): | 72 if auth.is_replica(): |
| 74 return | 73 return |
| 75 | 74 |
| 76 bots = auth.bootstrap_loopback_ips() | 75 bots = auth.bootstrap_loopback_ips() |
| 77 auth.bootstrap_group(BOTS_GROUP, bots, 'Swarming bots') | 76 auth.bootstrap_group(BOTS_GROUP, bots, 'Swarming bots') |
| 78 auth.bootstrap_group(USERS_GROUP, bots, 'Swarming users') | 77 auth.bootstrap_group(USERS_GROUP, bots, 'Swarming users') |
| 79 | 78 |
| 80 # Add a swarming admin. smoke-test@example.com is used in | 79 # Add a swarming admin. smoke-test@example.com is used in |
| 81 # server_smoke_test.py | 80 # server_smoke_test.py |
| 82 admin = auth.Identity(auth.IDENTITY_USER, 'smoke-test@example.com') | 81 admin = auth.Identity(auth.IDENTITY_USER, 'smoke-test@example.com') |
| 83 auth.bootstrap_group(ADMINS_GROUP, [admin], 'Swarming administrators') | 82 auth.bootstrap_group(ADMINS_GROUP, [admin], 'Swarming administrators') |
| 84 | 83 |
| 85 # Add an instance admin (for easier manual testing when running dev server). | 84 # Add an instance admin (for easier manual testing when running dev server). |
| 86 auth.bootstrap_group( | 85 auth.bootstrap_group( |
| 87 auth.ADMIN_GROUP, | 86 auth.ADMIN_GROUP, |
| 88 [auth.Identity(auth.IDENTITY_USER, 'test@example.com')], | 87 [auth.Identity(auth.IDENTITY_USER, 'test@example.com')], |
| 89 'Users that can manage groups') | 88 'Users that can manage groups') |
| OLD | NEW |