| OLD | NEW |
| 1 # Copyright 2013 The LUCI Authors. All rights reserved. | 1 # Copyright 2013 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 from components import auth | 5 from components import auth |
| 6 from components import utils | 6 from components import utils |
| 7 | 7 |
| 8 | 8 |
| 9 # Group with read and write access. | 9 # Group with read and write access. |
| 10 FULL_ACCESS_GROUP = 'isolate-access' | 10 FULL_ACCESS_GROUP = 'isolate-access' |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 """Returns True if current user can read from isolate.""" | 21 """Returns True if current user can read from isolate.""" |
| 22 return auth.is_group_member(READONLY_ACCESS_GROUP) or isolate_writable() | 22 return auth.is_group_member(READONLY_ACCESS_GROUP) or isolate_writable() |
| 23 | 23 |
| 24 | 24 |
| 25 def get_user_type(): | 25 def get_user_type(): |
| 26 """Returns a string describing the current access control for the user.""" | 26 """Returns a string describing the current access control for the user.""" |
| 27 if auth.is_admin(): | 27 if auth.is_admin(): |
| 28 return 'admin' | 28 return 'admin' |
| 29 if isolate_readable(): | 29 if isolate_readable(): |
| 30 return 'user' | 30 return 'user' |
| 31 return 'unknown user' | |
| 32 | 31 |
| 33 | 32 |
| 34 def bootstrap(): | 33 def bootstrap(): |
| 35 """Adds 127.0.0.1 as a whitelisted IP when testing.""" | 34 """Adds 127.0.0.1 as a whitelisted IP when testing.""" |
| 36 if not utils.is_local_dev_server() or auth.is_replica(): | 35 if not utils.is_local_dev_server() or auth.is_replica(): |
| 37 return | 36 return |
| 38 | 37 |
| 39 # Allow local bots full access. | 38 # Allow local bots full access. |
| 40 bots = auth.bootstrap_loopback_ips() | 39 bots = auth.bootstrap_loopback_ips() |
| 41 auth.bootstrap_group( | 40 auth.bootstrap_group( |
| 42 FULL_ACCESS_GROUP, bots, 'Can read and write from/to Isolate') | 41 FULL_ACCESS_GROUP, bots, 'Can read and write from/to Isolate') |
| 43 | 42 |
| 44 # Add a fake admin for local dev server. | 43 # Add a fake admin for local dev server. |
| 45 auth.bootstrap_group( | 44 auth.bootstrap_group( |
| 46 auth.ADMIN_GROUP, | 45 auth.ADMIN_GROUP, |
| 47 [auth.Identity(auth.IDENTITY_USER, 'test@example.com')], | 46 [auth.Identity(auth.IDENTITY_USER, 'test@example.com')], |
| 48 'Users that can manage groups') | 47 'Users that can manage groups') |
| OLD | NEW |