
    k7i                         S r SSKJr  SSKJrJrJr  SSKJrJ	r	  SSK
Jr  SSKJr  SSKJr  SSKJr  SS	KJrJr  \" \5      r " S
 S\5      r " S S\5      rg)a  Auth0 OAuth provider for FastMCP.

This module provides a complete Auth0 integration that's ready to use with
just the configuration URL, client ID, client secret, audience, and base URL.

Example:
    ```python
    from fastmcp import FastMCP
    from fastmcp.server.auth.providers.auth0 import Auth0Provider

    # Simple Auth0 OAuth protection
    auth = Auth0Provider(
        config_url="https://auth0.config.url",
        client_id="your-auth0-client-id",
        client_secret="your-auth0-client-secret",
        audience="your-auth0-api-audience",
        base_url="http://localhost:8000",
    )

    mcp = FastMCP("My Protected Server", auth=auth)
    ```
    )AsyncKeyValue)
AnyHttpUrl	SecretStrfield_validator)BaseSettingsSettingsConfigDict)	OIDCProxy)ENV_FILEparse_scopes)
get_logger)NotSetNotSetTc                   "   \ rS rSr% Sr\" S\SS9rSr\	S-  \
S'   Sr\S-  \
S'   Sr\S-  \
S	'   Sr\S-  \
S
'   Sr\	S-  \
S'   Sr\	S-  \
S'   Sr\S-  \
S'   Sr\\   S-  \
S'   Sr\\   S-  \
S'   Sr\S-  \
S'   \" SSS9\S 5       5       rSrg)Auth0ProviderSettings%   z!Settings for Auth0 OIDC provider.FASTMCP_SERVER_AUTH_AUTH0_ignore)
env_prefixenv_fileextraN
config_url	client_idclient_secretaudiencebase_url
issuer_urlredirect_pathrequired_scopesallowed_client_redirect_urisjwt_signing_keybefore)modec                     [        U5      $ )Nr   )clsvs     ]/home/james-whalen/.local/lib/python3.13/site-packages/fastmcp/server/auth/providers/auth0.py_parse_scopes#Auth0ProviderSettings._parse_scopes9   s     A     )__name__
__module____qualname____firstlineno____doc__r   r
   model_configr   r   __annotations__r   strr   r   r   r   r   r   r   listr    r!   r   classmethodr(   __static_attributes__r+   r*   r'   r   r   %   s    +%/L %)J
T!( IsTz &*M9t#*HcDj"&Hj4&$(J
T!( $M3:$(,OT#Y%,59 $s)d"29"&OS4Z&&X6  7r*   r   c                      ^  \ rS rSrSr\\\\\\\\\S\SS.S\\-  \-  S\\-  S\\-  S	\\-  S
\\-  \-  S\\-  \-  S\	\   \-  S\\-  S\	\   \-  S\
S-  S\\-  \-  S\SS4U 4S jjjrSrU =r$ )Auth0Provider?   a  An Auth0 provider implementation for FastMCP.

This provider is a complete Auth0 integration that's ready to use with
just the configuration URL, client ID, client secret, audience, and base URL.

Example:
    ```python
    from fastmcp import FastMCP
    from fastmcp.server.auth.providers.auth0 import Auth0Provider

    # Simple Auth0 OAuth protection
    auth = Auth0Provider(
        config_url="https://auth0.config.url",
        client_id="your-auth0-client-id",
        client_secret="your-auth0-client-secret",
        audience="your-auth0-api-audience",
        base_url="http://localhost:8000",
    )

    mcp = FastMCP("My Protected Server", auth=auth)
    ```
NT)r   r   r   r   r   r   r   r   r    client_storager!   require_authorization_consentr   r   r   r   r   r   r   r   r    r:   r!   r;   returnc                4  > [         R                  UUUUUUUUU	US.
R                  5        VVs0 s H  u  pU[        Ld  M  X_M     snn5      nUR                  (       d  [        S5      eUR                  (       d  [        S5      eUR                  (       d  [        S5      eUR                  (       d  [        S5      eUR                  (       d  [        S5      eUR                  =(       d    S/n[        TU ]1  UR                  UR                  UR                  R                  5       UR                  UR                  UR                  UR                  UUR                   U
UR"                  US9  [$        R'                  S	UR                  U5        g
s  snnf )a  Initialize Auth0 OAuth provider.

Args:
    config_url: Auth0 config URL
    client_id: Auth0 application client id
    client_secret: Auth0 application client secret
    audience: Auth0 API audience
    base_url: Public URL where OAuth endpoints will be accessible (includes any mount path)
    issuer_url: Issuer URL for OAuth metadata (defaults to base_url). Use root-level URL
        to avoid 404s during discovery when mounting under a path.
    required_scopes: Required Auth0 scopes (defaults to ["openid"])
    redirect_path: Redirect path configured in Auth0 application
    allowed_client_redirect_uris: List of allowed redirect URI patterns for MCP clients.
        If None (default), all URIs are allowed. If empty list, no URIs are allowed.
    client_storage: Storage backend for OAuth state (client registrations, encrypted tokens).
        If None, a DiskStore will be created in the data directory (derived from `platformdirs`). The
        disk store will be encrypted using a key derived from the JWT Signing Key.
    jwt_signing_key: Secret for signing FastMCP JWT tokens (any string or bytes). If bytes are provided,
        they will be used as is. If a string is provided, it will be derived into a 32-byte key. If not
        provided, the upstream client secret will be used to derive a 32-byte key using PBKDF2.
    require_authorization_consent: Whether to require user consent before authorizing clients (default True).
        When True, users see a consent screen before being redirected to Auth0.
        When False, authorization proceeds directly without user confirmation.
        SECURITY WARNING: Only disable for local development or testing environments.
)
r   r   r   r   r   r   r   r   r    r!   zRconfig_url is required - set via parameter or FASTMCP_SERVER_AUTH_AUTH0_CONFIG_URLzPclient_id is required - set via parameter or FASTMCP_SERVER_AUTH_AUTH0_CLIENT_IDzXclient_secret is required - set via parameter or FASTMCP_SERVER_AUTH_AUTH0_CLIENT_SECRETzNaudience is required - set via parameter or FASTMCP_SERVER_AUTH_AUTH0_AUDIENCEzNbase_url is required - set via parameter or FASTMCP_SERVER_AUTH_AUTH0_BASE_URLopenid)r   r   r   r   r   r   r   r   r    r:   r!   r;   z>Initialized Auth0 OAuth provider for client %s with scopes: %sN)r   model_validateitemsr   r   
ValueErrorr   r   r   r   r   super__init__get_secret_valuer   r   r    r!   loggerdebug)selfr   r   r   r   r   r   r   r   r    r:   r!   r;   kr&   settingsauth0_required_scopes	__class__s                    r'   rC   Auth0Provider.__init__W   s   R )77 #-!*%2 ( (",'6%24P'6 %'DA F? 
& ""d  !!b  %%j    `    `  !) 8 8 FXJ**(("00AAC&&&&**"001)1)N)N)$44*G 	 	
 	L!	
ys   F
F
r+   )r,   r-   r.   r/   r0   r   r   r3   r   r4   r   bytesboolrC   r6   __classcell__)rK   s   @r'   r8   r8   ?   s   4 28#)'-"(/517/5'-<B/317.2j
 $w.j
 =	j

 W}j
 -j
 s"W,j
 $w.j
 cW,j
 W}j
 '+3i'&9j
 &,j
 uw.j
 (,j
 
j
 j
r*   r8   N)r0   key_value.aio.protocolsr   pydanticr   r   r   pydantic_settingsr   r   fastmcp.server.auth.oidc_proxyr	   fastmcp.settingsr
   fastmcp.utilities.authr   fastmcp.utilities.loggingr   fastmcp.utilities.typesr   r   r,   rE   r   r8   r+   r*   r'   <module>rX      sK   . 2 ; ; > 4 % / 0 3	H	L 4B
I B
r*   