o
    tf                  	   @   sn   d Z ddlZddlZddlZddlZdd ZdddddddddZd	d
 ZdddZg dZ	de
fddZdS )zJA module with various utility methods for authorization in Jupyter Server.    Nc                   C   s   t jdtdd dS )zDEPRECATED, does nothingzCjupyter_server.auth.utils.warn_disabled_authorization is deprecated   )
stacklevelN)warningswarnDeprecationWarning r   r   b/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/jupyter_server/auth/utils.pywarn_disabled_authorization   s
   
r	   readwriteexecute)GETHEADOPTIONSPOSTPUTPATCHDELETEZ	WEBSOCKETc            	      C   s|   ddl m}  g }|  D ]	}|r|| qi }|D ]}t|}|j}|jD ]
}|d }|||< q'qdD ]}d||< q5|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+)Z	terminals)Zjupyter_server.serverappr   valuesextend	importlibimport_moduleZAUTH_RESOURCEZdefault_handlers)	r   modulesmod_nameZresource_mapZhandler_modulemodnamehandlerZ	url_regexr   r   r   get_regex_to_resource_map    s"   




r   c                 C   s<   |st  }| D ]\}}t|}|| r|  S q	d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)urlZregex_mappingregexZauth_resourcepatternr   r   r   match_url_to_resource@   s   

r&   )9ZMetisZAdrasteaZAmaltheaZThebeIoZEuropaZGanymedeZCallistoZThemistoZLedaZErsaZPandiaZHimaliaZLysitheaZElaraZDiaZCarpoZValetudoZEuporieZEuphemeZHelikeZEuantheZHermippeZ	PraxidikeZThyoneZ	ThelxinoeZAnankeZMnemeZOrthosieZ	HarpalykeZIocasteZErinomeZAitneZHerseZTaygeteZEukeladeZCarmeZIsonoeZAutonoeZPhilophrosyneZCylleneZPasitheeZPasiphaeZSpondeZEurydomeZKalykeZHegemoneZKaleZ
KallichoreZChaldeneZArcheZEireneZKoreZ	MegacliteZAoedeZ
CallirrhoeZSinopereturnc                   C   s   t tdtt d  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   r   get_anonymous_username   s   r.   )N)__doc__r   r+   r    r   r	   ZHTTP_METHOD_TO_AUTH_ACTIONr   r&   r*   strr.   r   r   r   r   <module>   s&    

 S