
    Wh                     T    d Z ddlZ G d dej                  Z G d d          ZdS )z9Experimental framework for authentication in TensorBoard.    Nc                       e Zd ZdZd ZdS )AuthProviderz:Authentication provider for a specific kind of credential.c                     dS )ae  Produce an opaque auth token from a WSGI request environment.

        Args:
          environ: A WSGI environment `dict`; see PEP 3333.

        Returns:
          A Python object representing an auth token. The representation
          and semantics depend on the particular `AuthProvider`
          implementation.

        Raises:
          Exception: Any error, usually `tensorboard.errors.PublicError`
            subclasses (like `PermissionDenied`) but also possibly a
            custom error type that should propagate to a WSGI middleware
            for effecting a redirect-driven auth flow.
        N )selfenvirons     V/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/tensorboard/auth.pyauthenticatezAuthProvider.authenticate   s	    " 	    N)__name__
__module____qualname____doc__r
   r   r   r	   r   r      s)        DD    r   r   )	metaclassc                   4    e Zd ZdZd Zed             Zd ZdS )AuthContexta  Authentication context within the scope of a single request.

    Auth providers are keyed within an `AuthContext` by arbitrary
    unique keys. It may often make sense for the key used for an
    auth provider to simply be that provider's type object.
    c                 0    || _         || _        i | _        dS )zCreate an auth context.

        Args:
          providers: A mapping from provider keys (opaque values) to
            `AuthProvider` implementations.
          environ: A WSGI environment (see PEP 3333).
        N)_environ
_providers_cache)r   	providersr   s      r	   __init__zAuthContext.__init__3   s      #r   c                      | i i           S )zCreate an auth context with no registered providers.

        Returns:
          A new `AuthContext` value for which any call to `get` will
          fail with a `KeyError`.
        r   )clss    r	   emptyzAuthContext.empty?   s     s2r{{r   c                     | j         |         }t                      }| j                            ||          }||ur|S |                    | j                  }|| j        |<   |S )a  Get an auth token from the auth provider with the given key.

        If successful, the result will be cached on this auth context.
        If unsuccessful, nothing will be cached, so a future call will
        invoke the underlying `AuthProvider.authenticate` method again.

        This method is not thread-safe. If multiple threads share an
        auth context for a single request, then they must synchronize
        externally when calling this method.

        Returns:
          The result of `provider.authenticate(...)` for the auth
          provider specified by `provider_key`.

        Raises:
          KeyError: If the given `provider_key` does not correspond to
            any registered `AuthProvider`.
          Exception: As raised by the underlying `AuthProvider`.
        )r   objectr   getr
   r   )r   provider_keyprovidersentinelvalues        r	   r   zAuthContext.getK   sd    ( ?<088h77  L%%dm44$)L!r   N)r   r   r   r   r   classmethodr   r   r   r   r	   r   r   +   sW         
 
 
 	 	 [	    r   r   )r   abcABCMetar   r   r   r   r	   <module>r&      sz    @ ? 



    S[    .; ; ; ; ; ; ; ; ; ;r   