
    g                     H    d dl Z d dlmZ d dlmZmZ dededefdZdefd	Zy)
    N)Request)GenerateKeyRequestUserAPIKeyAuthrequestapi_keyreturnc                    K   	 t        j                  d       d}||k(  rt        |      S t        # t        $ r t        w xY ww)NPROXY_MASTER_KEYz-1234)r   )osgetenvr   	Exception)r   r   modified_master_keys      b/var/www/openai/venv/lib/python3.12/site-packages/litellm/proxy/example_config_yaml/custom_auth.pyuser_api_key_authr      sO     !#+=!> ?uE))!'22 s   A(3 A3 AAdatac                   K   | j                         }|j                  d      }|j                  d       |j                  d       |j                  d       |j                  d       |j                  d       |j                  d       |j                  d       |j                  d	       |j                  d
       |j                  d       |t        |      dkD  rddiS dddS w)a  
    Asynchronously decides if a key should be generated or not based on the provided data.

    Args:
        data (GenerateKeyRequest): The data to be used for decision making.

    Returns:
        bool: True if a key should be generated, False otherwise.
    team_iddurationmodelsaliasesconfigspenduser_idmax_parallel_requestsmetadata	tpm_limit	rpm_limitr   decisionTz7This violates LiteLLM Proxy Rules. No team id provided.)r   message)jsongetlen)r   	data_jsonr   s      r   generate_key_fnr$      s      		I mmI&GMM*MM(MM)MM(MM'MM)MM)*MM*MM+MM+s7|a/
 	

 P
 	
s   C%C')	r   fastapir   litellm.proxy._typesr   r   strr   r$        r   <module>r*      s5    	  CW s ~ "
 2 "
r)   