%PDF- %PDF-
Direktori : /usr/lib/python3/dist-packages/twisted/web/_auth/__pycache__/ |
Current File : //usr/lib/python3/dist-packages/twisted/web/_auth/__pycache__/wrapper.cpython-312.pyc |
� Ϫ�f�! � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m Z ddlmZ ddl mZmZ ee� G d � d � � Z ee� G d� d� � Zy )a� A guard implementation which supports HTTP header-based authentication schemes. If no I{Authorization} header is supplied, an anonymous login will be attempted by using a L{Anonymous} credentials object. If such a header is supplied and does not contain allowed credentials, or if anonymous login is denied, a 401 will be sent in the response along with I{WWW-Authenticate} headers for each of the allowed authentication schemes. � )�implementer)�error)� Anonymous)�Logger)�proxyForInterface)�util)� IResource�_UnsafeErrorPagec �, � e Zd ZdZdZd� Zd� Zd� Zd� Zy)�UnauthorizedResourcez6 Simple IResource to escape Resource dispatch Tc � � || _ y �N)�_credentialFactories)�self� factoriess �;/usr/lib/python3/dist-packages/twisted/web/_auth/wrapper.py�__init__zUnauthorizedResource.__init__# s � �$-��!� c � ��� d� ���fd�}d� �|j d� | j D ]@ }|j |� }|j j d ||j |� � �B |j dk( ryy) z= Send www-authenticate headers to the client c �H � t | t � r| j d� S | S )N�ascii)� isinstance�str�encode��ss r �ensureBytesz0UnauthorizedResource.render.<locals>.ensureBytes+ s � �(2�1�c�(:�1�8�8�G�$�A��Ar c �� �� g }|j � D ]2 \ }} �|� } �|� }|j |dz �|� z � �4 dj | dj |� g� S )N� =� s , )�items�append�join)�scheme� challenge�lst�k�vr �quoteStrings ��r �generateWWWAuthenticatez<UnauthorizedResource.render.<locals>.generateWWWAuthenticate. sk �� ��C�!���)� 6���1���N����N��� � �1�t�8�k�!�n�4�5� 6� �9�9�f�e�j�j��o�6�7�7r c �R � d| j dd� j dd� z dz S )N� "� \s \\s \")�replacer s r r) z0UnauthorizedResource.render.<locals>.quoteString6 s* � ��!�)�)�E�6�2�:�:�4��H�H�4�O�Or i� s www-authenticates HEADr s Unauthorized)�setResponseCoder �getChallenge�responseHeaders�addRawHeaderr$ �method)r �requestr* �factr% r r) s @@r �renderzUnauthorizedResource.render&