
    Xh              	       f    d Z ddlZddlZddlZddlZd ZdddddddddZd Zdd	Zg d
Z	de
fdZy)zJA module with various utility methods for authorization in Jupyter Server.    Nc                  <    t        j                  dt        d       y)zDEPRECATED, does nothingzCjupyter_server.auth.utils.warn_disabled_authorization is deprecated   )
stacklevelN)warningswarnDeprecationWarning     M/var/www/html/myenv/lib/python3.12/site-packages/jupyter_server/auth/utils.pywarn_disabled_authorizationr      s    MMMr
   readwriteexecute)GETHEADOPTIONSPOSTPUTPATCHDELETE	WEBSOCKETc                  
   ddl m}  g }| j                         D ]  }|s|j                  |        i }|D ]>  }t	        j
                  |      }|j                  }|j                  D ]  }|d   }|||<    @ dD ]  }d||<   	 |S )zReturns a dictionary with all of Jupyter Server's
    request handler URL regex patterns mapped to
    their resource name.

    e.g.
    { "/api/contents/<regex_pattern>": "contents", ...}
    r   )JUPYTER_SERVICE_HANDLERS)z/terminals/websocket/(\w+)z/api/terminalsz/api/terminals/(\w+)	terminals)jupyter_server.serverappr   valuesextend	importlibimport_moduleAUTH_RESOURCEdefault_handlers)	r   modulesmod_nameresource_maphandler_modulemodnamehandler	url_regexs	            r   get_regex_to_resource_mapr*       s     BG,335 %NN8$% L! +%%n5  ++ 	+G
I&*L#	++ .	
 #.Y. r
   c                     |s
t               }|j                         D ]/  \  }}t        j                  |      }|j	                  |       s-|c S  y)zFinds the JupyterHandler regex pattern that would
    match the given URL and returns the resource name (str)
    of that handler.

    e.g.
    /api/contents/... returns "contents"
    N)r*   itemsrecompile	fullmatch)urlregex_mappingregexauth_resourcepatterns        r   match_url_to_resourcer5   @   sN     13 - 3 3 5 !}**U#S!  !r
   )9MetisAdrasteaAmaltheaThebeIoEuropaGanymedeCallistoThemistoLedaErsaPandiaHimaliaLysitheaElaraDiaCarpoValetudoEuporieEuphemeHelikeEuantheHermippe	PraxidikeThyone	ThelxinoeAnankeMnemeOrthosie	HarpalykeIocasteErinomeAitneHerseTaygeteEukeladeCarmeIsonoeAutonoePhilophrosyneCyllenePasitheePasiphaeSpondeEurydomeKalykeHegemoneKale
KallichoreChaldeneArcheEireneKore	MegacliteAoede
CallirrhoeSinopereturnc                  \    t         t        j                  dt        t               dz
           S )z
    Get a random user-name based on the moons of Jupyter.
    This function returns names like "Anonymous Io" or "Anonymous Metis".
    r      )moons_of_jupyterrandomrandintlenr	   r
   r   get_anonymous_usernamerv      s%    
 FNN1c2B.Ca.GHIIr
   )N)__doc__r   rs   r-   r   r   HTTP_METHOD_TO_AUTH_ACTIONr*   r5   rr   strrv   r	   r
   r   <module>rz      s`    P   	  	 @!"P fJ Jr
   