U
    d                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ dZ	dZ
d	Zd
ZzddlZW n ek
rl   ee	Y nX dddZdddZdS )zMessage Signing Serializer.    )disable_insecure_serializers)registry)ImproperlyConfigured   )register_authz|You need to install the cryptography library to use the auth serializer.
Please install by:

    $ pip install cryptography
zSorry, but you have to configure the
    * security_key
    * security_certificate, and the
    * security_cert_store
configuration settings to use the auth serializer.

Please see the configuration reference for more information.
a  You have to configure a special task serializer
for signing and verifying tasks:
    * task_serializer = 'auth'

You have to accept only tasks which are serialized with 'auth'.
There is no point in signing messages if they are not verified.
    * accept_content = ['auth']
)setup_securityNjsonc              
   C   s   |dkrddl m} | }t|  |j}|jdks@|jdgkrHtt|pP|j	}|pZ|j
}|pd|j}|pn|j}|r||r||sttt|2}	t|}
t|	 |
 ||| W 5 Q R X W 5 Q R X td dS )z#See :meth:`@Celery.setup_security`.Nr   )current_appauth)Zceleryr	   Z_get_current_object_disable_insecure_serializersconfZtask_serializerZaccept_contentr   SETTING_MISSINGZsecurity_keyZsecurity_certificateZsecurity_cert_storeZsecurity_digestSECURITY_SETTING_MISSINGopenr   readr   Z_set_default_serializer)Zallowed_serializerskeycertstoredigest
serializerZappr	   r   Zkfcf r   </tmp/pip-unpacked-wheel-mu1yl971/celery/security/__init__.pyr   -   s"    





,r   c                 C   s   t | d d S )N)allowed)r   )	whitelistr   r   r   disable_untrusted_serializersI   s    r   )NNNNNr   N)N)__doc__Zkombu.serializationr   r   r   Zcelery.exceptionsr   Zserializationr   ZCRYPTOGRAPHY_NOT_INSTALLEDr   r   __all__ZcryptographyImportErrorr   r   r   r   r   r   <module>   s$   

      
