
    D6i                     f    d dl mZ d dlmZ d dlmZ dZ	 	 d
ddddddddddddddZ ed	       Zy)    )g)
LocalProxy)OAuth2ConsumerBlueprintz,Steven MARTINS <steven.martins.fr@gmail.com>Ncommon)scoperedirect_urlredirect_to	login_urlauthorized_urlsession_classstoragetenantpromptdomain_hint
login_hintrule_kwargsc                   |xs g d}d|	 d}d|	 d}i }|r||d<   |r||d<   |
r|
|d<   t        dt        f| ||d	||d
|v r|nd||||||||ddj                  d<   dj                  d<   j                  fd       }S )a=  
    Make a blueprint for authenticating with Azure AD using OAuth 2. This requires
    a client ID and client secret from Azure AD. You should either pass them to
    this constructor, or make sure that your Flask application config defines
    them, using the variables :envvar:`AZURE_OAUTH_CLIENT_ID` and
    :envvar:`AZURE_OAUTH_CLIENT_SECRET`.

    Args:
        client_id (str): The client ID for your application on Azure AD.
        client_secret (str): The client secret for your application on Azure AD
        scope (str, optional): comma-separated list of scopes for the OAuth token.
            If the ``offline_access`` scope is included, automatic token refresh
            will be enabled. `See the Azure documentation for more information.
            <https://learn.microsoft.com/en-us/entra/identity-platform/scopes-oidc#the-offline_access-scope>`_
        redirect_url (str): the URL to redirect to after the authentication
            dance is complete
        redirect_to (str): if ``redirect_url`` is not defined, the name of the
            view to redirect to after the authentication dance is complete.
            The actual URL will be determined by :func:`flask.url_for`
        login_url (str, optional): the URL path for the ``login`` view.
            Defaults to ``/azure``
        authorized_url (str, optional): the URL path for the ``authorized`` view.
            Defaults to ``/azure/authorized``.
        session_class (class, optional): The class to use for creating a
            Requests session. Defaults to
            :class:`~flask_dance.consumer.requests.OAuth2Session`.
        storage: A token storage class, or an instance of a token storage
                class, to use for this blueprint. Defaults to
                :class:`~flask_dance.consumer.storage.session.SessionStorage`.
        tenant: Determine which accounts are allowed to authenticate with Azure.
                `See the Azure documentation for more information about this parameter.
                <https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols#endpoints>`_
                Defaults to ``common``.
        prompt (str, optional): Indicate the type of user interaction that is required.
            Valid values are ``login``, ``select_account``, ``consent``, ``admin_consent``.
            Learn more about the options `here.
            <https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-protocols-oauth-code#request-an-authorization-code>`_
            Defaults to ``None``
        domain_hint (str, optional): Provides a hint about the tenant or domain that
            the user should use to sign in. The value of the domain_hint is a
            registered domain for the tenant. If the tenant is federated to an
            on-premises directory, AAD redirects to the specified tenant federation server.
            Defaults to ``None``
        login_hint (str, optional): Can be used to pre-fill the username/email
            address field of the sign-in page for the user, if you know their
            username ahead of time. Often apps use this parameter during re-authentication,
            having already extracted the username from a previous sign-in using the
            preferred_username claim.
            Defaults to ``None``
        rule_kwargs (dict, optional): Additional arguments that should be passed when adding
            the login and authorized routes. Defaults to ``None``.

    :rtype: :class:`~flask_dance.consumer.OAuth2ConsumerBlueprint`
    :returns: A :doc:`blueprint <flask:blueprints>` to attach to your Flask app.
    )openidemailprofilez	User.Readz"https://login.microsoftonline.com/z/oauth2/v2.0/tokenz/oauth2/v2.0/authorizer   r   r   azurezhttps://graph.microsoft.comoffline_accessN)	client_idclient_secretr   base_urlauthorization_url	token_urlauto_refresh_urlr   r	   r
   r   authorization_url_paramsr   r   r   AZURE_OAUTH_CLIENT_IDr   AZURE_OAUTH_CLIENT_SECRETr   c                  0     j                   t        _        y N)sessionr   flask_dance_azure)azure_bps   \/home/azureuser/techstart-app/venv/lib/python3.12/site-packages/flask_dance/contrib/azure.pyset_applocal_sessionz2make_azure_blueprint.<locals>.set_applocal_sessions   s    &..    )r   __name__from_configbefore_app_request)r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r(   r&   s                     @r'   make_azure_blueprintr-   	   s    P @@E4VH<NOI
,VH4JK   "1; .2= /-3 *& #.+&6%&?T!%!9##H& )@H%,GH)  / !/ Or)   c                  "    t         j                  S r#   )r   r%    r)   r'   <lambda>r0   z   s    1.. r)   )NN)	flaskr   werkzeug.localr   flask_dance.consumerr   __maintainer__r-   r   r/   r)   r'   <module>r5      s[     % 8? n nb 	./r)   