
    Mh              	       h    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dS )zJA module with various utility methods for authorization in Jupyter Server.    Nc                  >    t          j        dt          d           dS )zDEPRECATED, does nothingzCjupyter_server.auth.utils.warn_disabled_authorization is deprecated   )
stacklevelN)warningswarnDeprecationWarning     Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jupyter_server/auth/utils.pywarn_disabled_authorizationr      s.    MM     r
   readwriteexecute)GETHEADOPTIONSPOSTPUTPATCHDELETE	WEBSOCKETc                      ddl m}  g }|                                 D ]}|r|                    |           i }|D ]4}t	          j        |          }|j        }|j        D ]}|d         }|||<   5d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AAAAAG,3355 % % 	%NN8$$$L! + +%n55 + 	+ 	+G
I&*L##	+
 . .	
 #.Yr
   c                     |st                      }|                                D ]2\  }}t          j        |          }|                    |           r|c S 3dS )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   @   sw      4133 - 3 3 5 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                  l    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)    
 FN1c2B.C.Ca.GH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      				    	 	   @! ! ! !"P P P fJ J J J J J Jr
   