
    Xhs
                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZ erddlmZ dd	lmZ  G d
 de      Z G d de      Zy)zAn Authorizer for use in the Jupyter server.

The default authorizer (AllowAllAuthorizer)
allows all authenticated requests

.. versionadded:: 2.0
    )annotations)TYPE_CHECKING)Instance)LoggingConfigurable   )IdentityProviderUser)	Awaitable)JupyterHandlerc                  <    e Zd ZdZ ee      Z	 	 	 	 	 	 	 	 	 	 ddZy)
Authorizera  Base class for authorizing access to resources
    in the Jupyter Server.

    All authorizers used in Jupyter Server
    should inherit from this base class and, at the very minimum,
    implement an ``is_authorized`` method with the
    same signature as in this base class.

    The ``is_authorized`` method is called by the ``@authorized`` decorator
    in JupyterHandler. If it returns True, the incoming request
    to the server is accepted; if it returns False, the server
    returns a 403 (Forbidden) error code.

    The authorization check will only be applied to requests
    that have already been authenticated.

    .. versionadded:: 2.0
    c                    t         )a  A method to determine if ``user`` is authorized to perform ``action``
        (read, write, or execute) on the ``resource`` type.

        Parameters
        ----------
        user : jupyter_server.auth.User
            An object representing the authenticated user,
            as returned by :meth:`jupyter_server.auth.IdentityProvider.get_user`.

        action : str
            the category of action for the current request: read, write, or execute.

        resource : str
            the type of resource (i.e. contents, kernels, files, etc.) the user is requesting.

        Returns
        -------
        bool
            True if user authorized to make request; False, otherwise
        )NotImplementedErrorselfhandleruseractionresources        R/var/www/html/myenv/lib/python3.12/site-packages/jupyter_server/auth/authorizer.pyis_authorizedzAuthorizer.is_authorized0   s
    . "!    N)
r   r   r   r	   r   strr   r   returnzAwaitable[bool] | bool)__name__
__module____qualname____doc__r   r   identity_providerr    r   r   r   r      sB    & !!12"%"-1";>"JM"	"r   r   c                  ,    e Zd ZdZ	 	 	 	 	 	 	 	 	 	 ddZy)AllowAllAuthorizerzA no-op implementation of the Authorizer

    This authorizer allows all authenticated requests.

    .. versionadded:: 2.0
    c                     y)z|This method always returns True.

        All authenticated users are allowed to do anything in the Jupyter Server.
        Tr    r   s        r   r   z AllowAllAuthorizer.is_authorizedR   s     r   N)
r   r   r   r	   r   r   r   r   r   bool)r   r   r   r   r   r    r   r   r"   r"   J   s4    %-1;>JM	r   r"   N)r   
__future__r   typingr   	traitletsr   traitlets.configr   identityr   r	   collections.abcr
   jupyter_server.base.handlersr   r   r"   r    r   r   <module>r,      s>    #    0 ,);-"$ -"` r   