MCPcopy
hub / github.com/feast-dev/feast / assert_permissions

Function assert_permissions

sdk/python/feast/permissions/security_manager.py:141–165  ·  view source on GitHub ↗

A utility function to invoke the `assert_permissions` method on the global security manager. If no global `SecurityManager` is defined, the execution is permitted. Args: resource: The resource for which we need to enforce authorized permission. actions: The requested a

(
    resource: FeastObject,
    actions: Union[AuthzedAction, List[AuthzedAction]],
)

Source from the content-addressed store, hash-verified

139
140
141def assert_permissions(
142 resource: FeastObject,
143 actions: Union[AuthzedAction, List[AuthzedAction]],
144) -> FeastObject:
145 """
146 A utility function to invoke the `assert_permissions` method on the global security manager.
147
148 If no global `SecurityManager` is defined, the execution is permitted.
149
150 Args:
151 resource: The resource for which we need to enforce authorized permission.
152 actions: The requested actions to be authorized.
153 Returns:
154 FeastObject: The original `resource`, if permitted.
155
156 Raises:
157 FeastPermissionError: If the current user is not authorized to execute the requested actions on the given resources.
158 """
159
160 sm = get_security_manager()
161 if not is_auth_necessary(sm):
162 return resource
163 return sm.assert_permissions( # type: ignore[union-attr]
164 resources=[resource], actions=actions, filter_only=False
165 )[0]
166
167
168def permitted_resources(

Callers 15

GetEntityMethod · 0.90
DeleteEntityMethod · 0.90
GetDataSourceMethod · 0.90
DeleteDataSourceMethod · 0.90
GetFeatureViewMethod · 0.90
GetAnyFeatureViewMethod · 0.90
ListAllFeatureViewsMethod · 0.90
DeleteFeatureViewMethod · 0.90
GetStreamFeatureViewMethod · 0.90
GetLabelViewMethod · 0.90
GetFeatureServiceMethod · 0.90

Calls 3

get_security_managerFunction · 0.85
is_auth_necessaryFunction · 0.85
assert_permissionsMethod · 0.80

Tested by 1