
    1Vh                     P    d Z ddlZ G d dej                        Z G d d      Zy)z9Experimental framework for authentication in TensorBoard.    Nc                       e Zd ZdZd Zy)AuthProviderz:Authentication provider for a specific kind of credential.c                      y)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     @/home/dcms/DCMS/lib/python3.12/site-packages/tensorboard/auth.pyauthenticatezAuthProvider.authenticate   s    " 	    N)__name__
__module____qualname____doc__r
   r   r   r	   r   r      s
    Dr   r   )	metaclassc                   ,    e Zd ZdZd Zed        Zd Zy)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                 .    || _         || _        i | _        y)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     2r{r   c                     | j                   |   }t               }| j                  j                  ||      }||ur|S |j	                  | 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   sa    ( ??<08h7 L%%dmm4$)L!r   N)r   r   r   r   r   classmethodr   r   r   r   r	   r   r   +   s%    
 	 	r   r   )r   abcABCMetar   r   r   r   r	   <module>r&      s(    @ 
S[[ .; ;r   