Ë
    tPêjÏ  ã                   ób   — d Z ddlmZ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
„Z
dedd	fd„Zy	)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.
é    )ÚFinalÚLiteral)ÚHTTPException)ÚLitellmUserRolesÚUserAPIKeyAuth)ÚagentsÚvector_storesÚuser_api_key_dictÚfeature_nameÚreturnNc              ƒ   ó   K  — | j                   t        j                  t        j                  t        j                  j                  t        j                  j                  fv ryddlm}m}m} d|› d�}d|› d�}|j                  |d«      sy|j                  |d«      rdd	l
m}  || ||¬
«      ƒ d{  –—† }|ryt        ddd|› d�i¬«      ‚7 Œ­w)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_cacheÚdisable_Ú_for_internal_usersÚallow_Ú_for_team_adminsF)Ú_user_has_admin_privileges)r
   r   r   é“  Úerrorz
Access to z5 is disabled for your role. Contact your proxy admin.©Ústatus_codeÚdetail)Ú	user_roler   ÚPROXY_ADMINÚPROXY_ADMIN_VIEW_ONLYÚvalueÚlitellm.proxy.proxy_serverr   r   r   ÚgetÚ/litellm.proxy.management_endpoints.common_utilsr   r   )	r
   r   r   r   r   Údisable_flagÚallow_team_admins_flagr   Úis_admins	            új/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/proxy/common_utils/rbac_utils.pyÚcheck_feature_access_for_userr&      sï   è ø€ ð ×"Ñ"Ü×$Ñ$Ü×.Ñ.Ü×$Ñ$×*Ñ*Ü×.Ñ.×4Ñ4ð	'ñ ð 	÷ñ ð % \ NÐ2EÐF€LØ&,¨\¨NÐ:JÐ$KÐà×Ñ ¨eÔ4àð ×ÑÐ2°EÔ:õ	
ñ !;Ø/Ø'Ø1ô!
÷ 
ˆñ
 Øä
ØØ˜: l ^Ð3hÐiÐjôð ð
ús   ‚B/CÂ1CÂ2Cc              ƒ   óÈ   K  — | j                   t        j                  t        j                  j                  fvryddlm} |j                  dd«      syt        dddi¬	«      ‚­w)
u  
    Raise HTTP 403 if the caller is an org admin and key generation is
    disabled for org admins via UI settings.

    Only blocks the ORG_ADMIN role â€” proxy admins and all other roles are
    unaffected, so those paths continue to be gated by their existing auth
    checks.
    Nr   )r   Ú"disable_key_generate_for_org_adminFr   r   zDkey generation is disabled for org admins. Contact your proxy admin.r   )r   r   Ú	ORG_ADMINr   r   r   r    r   )r
   r   s     r%   Ú!check_org_admin_can_generate_keysr*   G   sh   è ø€ ð ×"Ñ"Ü×"Ñ"Ü×"Ñ"×(Ñ(ð+ñ ð 	å;à×ÑÐ DÀeÔLØä
ØØÐ_Ð`ôð ùs   ‚A A")Ú__doc__Útypingr   r   Úfastapir   Úlitellm.proxy._typesr   r   ÚFeatureNamer&   r*   © ó    r%   ú<module>r2      sU   ðñ÷ "å !ç AàÐ/Ñ0€ð3Ø%ð3àð3ð 
ó3ðlØ%ðà	ôr1   