o
    ưi@                     @   sN   d Z ddlmZ ddlmZ ddlmZmZ ed Zdededd	fd
dZ	d	S )z
RBAC utility helpers for feature-level access control.

These helpers are used by agent and vector store endpoints to enforce
proxy-admin-configurable toggles that restrict access for internal users.
    )Literal)HTTPException)LitellmUserRolesUserAPIKeyAuth)ZagentsZvector_storesuser_api_key_dictfeature_namereturnNc           	         s   | j tjtjtjjtjjfv rdS ddlm}m}m} d| d}d| d}|	|ds0dS |	|drJdd	l
m} || ||d
I dH }|rJdS tddd| did)a  
    Raise HTTP 403 if the user's role is blocked from accessing the given feature
    by the UI settings stored in general_settings.

    Args:
        user_api_key_dict: The authenticated user.
        feature_name: Either "agents" or "vector_stores".
    Nr   )general_settingsprisma_clientuser_api_key_cacheZdisable_Z_for_internal_usersZallow_Z_for_team_adminsF)_user_has_admin_privileges)r   r
   r   i  errorz
Access to z5 is disabled for your role. Contact your proxy admin.)status_codedetail)Z	user_roler   ZPROXY_ADMINZPROXY_ADMIN_VIEW_ONLYvalueZlitellm.proxy.proxy_serverr	   r
   r   getZ/litellm.proxy.management_endpoints.common_utilsr   r   )	r   r   r	   r
   r   Zdisable_flagZallow_team_admins_flagr   Zis_admin r   \/home/app/Keep/.python/lib/python3.10/site-packages/litellm/proxy/common_utils/rbac_utils.pycheck_feature_access_for_user   s6   r   )
__doc__typingr   Zfastapir   Zlitellm.proxy._typesr   r   ZFeatureNamer   r   r   r   r   <module>   s    