a
    ø£Be7
  ã                   @  sx   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rTddlmZ G d	d
„ d
eƒZG dd„ deƒZdS )z“An 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)ÚJupyterHandlerc                   @  s.   e Zd ZdZeeƒZddddddœdd„Zd	S )
Ú
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
    r	   r   ÚstrÚbool©ÚhandlerÚuserÚactionÚresourceÚreturnc                 C  s
   t ƒ ‚dS )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
        N)ÚNotImplementedError©Úselfr   r   r   r   © r   úa/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/jupyter_server/auth/authorizer.pyÚis_authorized-   s    zAuthorizer.is_authorizedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Zidentity_providerr   r   r   r   r   r
      s   r
   c                   @  s&   e Zd ZdZddddddœdd„Zd	S )
ÚAllowAllAuthorizerz€A no-op implementation of the Authorizer

    This authorizer allows all authenticated requests.

    .. versionadded:: 2.0
    r	   r   r   r   r   c                 C  s   dS )z|This method always returns True.

        All authenticated users are allowed to do anything in the Jupyter Server.
        Tr   r   r   r   r   r   O   s    z AllowAllAuthorizer.is_authorizedN)r   r   r   r   r   r   r   r   r   r   G   s   r   N)r   Ú
__future__r   Útypingr   Z	traitletsr   Ztraitlets.configr   Úidentityr   r   Zjupyter_server.base.handlersr	   r
   r   r   r   r   r   Ú<module>   s   	0