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]],
)
| 139 | |
| 140 | |
| 141 | def 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 | |
| 168 | def permitted_resources( |