
    AHj                     @    d Z ddlmZ ddlmZmZ ddlmZ dedefdZy)	a  
Example Custom SSO Handler

Use this if you want to run custom code after litellm has retrieved information from your IDP (Identity Provider).

Flow:
- User lands on Admin UI
- LiteLLM redirects user to your SSO provider
- Your SSO provider redirects user back to LiteLLM
- LiteLLM has retrieved user information from your IDP
- Your custom SSO handler is called and returns an object of type SSOUserDefinedValues
- User signed in to UI
    )OpenID)LitellmUserRolesSSOUserDefinedValues)proxy_serveruserIDPInforeturnc                 r  K   	 | j                   t        d|        t        j                  2t        j                  j	                  | j                          d {   }t        g | j                   | j                  t        j                  j                  dd      S 7 A# t        $ r t        d      w xY ww)Nz-No ID found for user. userIDPInfo.id is None )user_id
   1d)modelsr
   
user_email	user_role
max_budgetbudget_durationzFailed custom auth)id
ValueErrorr   prisma_clientget_datar   emailr   INTERNAL_USERvalue	Exception)r   
_user_infos     P/root/tools/cai/cai_env/lib/python3.12/site-packages/litellm/proxy/custom_sso.pycustom_sso_handlerr      s     .>>!?}M  %%1+99BB#  C   J $NN"((&44:: 
 	
	  .,--.s0   B7AB BA B B7B B44B7N)	__doc__fastapi_sso.sso.baser   litellm.proxy._typesr   r   litellm.proxyr   r        r   <module>r#      s)    ( G &.& .5I .r"   