
    g                     @    d Z ddlmZmZmZ dedefdZdededefdZy)	z*
Checks for LiteLLM service account keys

    )ProxyErrorTypesProxyExceptionUserAPIKeyAuthvalid_tokenreturnc                 :    | j                   rd| j                   v ryy)zr
    Checks if the token is a service account

    Returns:
        bool: True if token is a service account

    service_account_idTF)metadata)r   s    ^/var/www/openai/venv/lib/python3.12/site-packages/litellm/proxy/auth/service_account_checks.py!check_if_token_is_service_accountr   	   s!     ;#7#77    request_datac           	         K   t        |       duryddlm} d|v rD|d   }d|v r;|d   }|D ]1  }||vst        t        j
                  j                  d|d| d	       yw)
z
    If a virtual key is a service account, checks it's a valid service account

    A token is a service account if it has a service_account_id in its metadata

    Service Account Specific Checks:
        - Check if required_params is set
    Tr   )general_settingsservice_account_settingsenforced_paramsi  zBadRequest please pass param=z> in request body. This is a required param for service account)typecodeparammessage)r   litellm.proxy.proxy_serverr   r   r   bad_request_errorvalue)r   r   r   r   _enforced_paramsr   s         r   service_account_checksr      s      )5TA;!%55#34N#O  8878IJ),(,>>DD #"?w  GE  !F	  * s
   0A -A N)	__doc__litellm.proxy._typesr   r   r   boolr   dictr    r   r   <module>r!      sC   
 Q P> d /3	r   