
    ^h              	       j    S r SSKrSSKrSSKrSSKrS rSSSSSSSSS.rS rSS	 jr/ S
Qr	S\
4S jrg)zJA module with various utility methods for authorization in Jupyter Server.    Nc                  8    [         R                  " S[        SS9  g)zDEPRECATED, does nothingzCjupyter_server.auth.utils.warn_disabled_authorization is deprecated   )
stacklevelN)warningswarnDeprecationWarning     S/home/james-whalen/.local/lib/python3.13/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                  $   SSK Jn   / nU R                  5        H  nU(       d  M  UR                  U5        M     0 nU HA  n[        R
                  " U5      nUR                  nUR                   H  nUS   nXcU'   M     MC     S H  nSX8'   M	     U$ )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8NN8$ 6 L!%%n5  ++G
I&*# , "	
 #. r
   c                     U(       d
  [        5       nUR                  5        H5  u  p#[        R                  " U5      nUR	                  U 5      (       d  M3  Us  $    g)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   @   sJ     13 - 3 3 5**U#S!!   !6r
   )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                  ^    [         [        R                  " S[        [         5      S-
  5         $ )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
   