o
    i                  	   @   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 )zKA 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   T/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/jupyter_server/auth/utils.pywarn_disabled_authorization   s
   
r	   readwriteexecute)GETHEADOPTIONSPOSTPUTPATCHDELETE	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+)	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_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)urlregex_mappingregexauth_resourcepatternr   r   r   match_url_to_resource@   s   

r0   )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                   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   rp   )N)__doc__r   rm   r(   r   r	   HTTP_METHOD_TO_AUTH_ACTIONr&   r0   rl   strrp   r   r   r   r   <module>   s&    

 S