|
| 1 | +module VCAP::CloudController |
| 2 | + class ServiceUsageConsumerAccess < BaseAccess |
| 3 | + def create?(_object, _params=nil) |
| 4 | + admin_user? |
| 5 | + end |
| 6 | + |
| 7 | + def read?(object) |
| 8 | + return @ok_read if instance_variable_defined?(:@ok_read) |
| 9 | + |
| 10 | + @ok_read = admin_user? || admin_read_only_user? || global_auditor? || object_is_visible_to_user?(object, context.user) |
| 11 | + end |
| 12 | + |
| 13 | + def read_for_update?(_object, _params=nil) |
| 14 | + admin_user? |
| 15 | + end |
| 16 | + |
| 17 | + def can_remove_related_object?(object, params=nil) |
| 18 | + read_for_update?(object, params) |
| 19 | + end |
| 20 | + |
| 21 | + def read_related_object_for_update?(object, params=nil) |
| 22 | + read_for_update?(object, params) |
| 23 | + end |
| 24 | + |
| 25 | + def update?(_object, _params=nil) |
| 26 | + admin_user? |
| 27 | + end |
| 28 | + |
| 29 | + def delete?(_object) |
| 30 | + admin_user? |
| 31 | + end |
| 32 | + |
| 33 | + # These methods should be called first to determine if the user's token has the appropriate scope for the operation |
| 34 | + |
| 35 | + def read_with_token?(_) |
| 36 | + admin_user? || admin_read_only_user? || has_read_scope? || global_auditor? |
| 37 | + end |
| 38 | + |
| 39 | + def create_with_token?(_) |
| 40 | + admin_user? || has_write_scope? |
| 41 | + end |
| 42 | + |
| 43 | + def read_for_update_with_token?(_) |
| 44 | + admin_user? || has_write_scope? |
| 45 | + end |
| 46 | + |
| 47 | + def can_remove_related_object_with_token?(*) |
| 48 | + read_for_update_with_token?(*) |
| 49 | + end |
| 50 | + |
| 51 | + def read_related_object_for_update_with_token?(*) |
| 52 | + read_for_update_with_token?(*) |
| 53 | + end |
| 54 | + |
| 55 | + def update_with_token?(_) |
| 56 | + admin_user? || has_write_scope? |
| 57 | + end |
| 58 | + |
| 59 | + def delete_with_token?(_) |
| 60 | + admin_user? || has_write_scope? |
| 61 | + end |
| 62 | + |
| 63 | + def index_with_token?(_) |
| 64 | + admin_user? || admin_read_only_user? |
| 65 | + end |
| 66 | + |
| 67 | + def index?(_object_class, _params=nil) |
| 68 | + admin_user? || admin_read_only_user? |
| 69 | + end |
| 70 | + |
| 71 | + def reset?(_object_class) |
| 72 | + admin_user? |
| 73 | + end |
| 74 | + |
| 75 | + def reset_with_token?(_object_class) |
| 76 | + admin_user? |
| 77 | + end |
| 78 | + end |
| 79 | +end |
0 commit comments