
    Vvg                         d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZmZmZ d dlmZmZmZmZmZ  ee          Z G d d	ee          Zd
S )    )	getLogger)Optional)import_string)now)settings)AxesBaseHandlerAbstractAxesHandlerAxesHandler)get_client_ip_addressget_client_user_agentget_client_path_infoget_client_http_accept
toggleablec            
          e Zd ZdZdZeddedefd            Zeddddde	e
         d	e	e
         d
edefd            Zeddde	e         defd            Zeddde	e         defd            Zeddd	e
de	e         defd            Zed             Zedde	e         defd            Zedde	e         defd            Zedde	e         defd            Zeeddefd                        Zeed                         Zeed                         Zeed                         Zeed                         ZdS )AxesProxyHandlera  
    Proxy interface for configurable Axes signal handler class.

    If you wish to implement a custom version of this handler,
    you can override the settings.AXES_HANDLER configuration string
    with a class that implements a compatible interface and methods.

    Defaults to using axes.handlers.proxy.AxesProxyHandler if not overridden.
    Refer to axes.handlers.proxy.AxesProxyHandler for default implementation.
    NFforcereturnc                 n    |s| j         s& t          t          j                              | _         | j         S )z
        Fetch and initialize configured handler implementation and memoize it to avoid reinitialization.

        This method is re-entrant and can be called multiple times from e.g. Django application loader.
        )implementationr   r   AXES_HANDLER)clsr   s     P/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/axes/handlers/proxy.pyget_implementationz#AxesProxyHandler.get_implementation%   s<      	H* 	H!Ex/D!E!E!G!GC!!    
ip_addressusernameip_or_usernamer   r   r   c                V    |                                                      |||          S )Nr   )r   reset_attempts)r   r   r   r   s       r   r    zAxesProxyHandler.reset_attempts1   s4     %%''66!H^ 7 
 
 	
r   age_daysr"   c                R    |                                                      |          S Nr!   )r   
reset_logsr   r"   s     r   r%   zAxesProxyHandler.reset_logs=   s%    %%''22H2EEEr   c                R    |                                                      |          S r$   )r   reset_failure_logsr&   s     r   r(   z#AxesProxyHandler.reset_failure_logsA   s%    %%''::H:MMMr   )limitr)   c                R    |                                                      |          S )N)r   )r    remove_out_of_limit_failure_logs)r   r   r)   s      r   r+   z1AxesProxyHandler.remove_out_of_limit_failure_logsE   s1     %%''HH I 
 
 	
r   c                    | t                               d           dS t          | d          st          | d          sd| _        t	                      | _        t          |           | _        t          |           | _	        t          |           | _        t          |           | _        d| _        d| _        d| _        dS dS )z`
        Update request attributes before passing them into the selected handler class.
        NzVAXES: AxesProxyHandler.update_request can not set request attributes to a None requestaxes_updatedaxes_locked_outFT)logerrorhasattrr.   r   axes_attempt_timer   axes_ip_addressr   axes_user_agentr   axes_path_infor   axes_http_acceptaxes_failures_since_startr-   axes_credentials)requests    r   update_requestzAxesProxyHandler.update_requestM   s     ?IIh   Fw// 
	,7$566 0*/'(+G%&;G&D&DG#&;G&D&DG#%9'%B%BG"'=g'F'FG$04G-#'G '+G$$$
	, 
	,r   credentialsc                 |    |                      |           |                                                     ||          S N)r:   r   	is_lockedr   r9   r;   s      r   r>   zAxesProxyHandler.is_lockedd   s8    7###%%''11';GGGr   c                 |    |                      |           |                                                     ||          S r=   )r:   r   
is_allowedr?   s      r   rA   zAxesProxyHandler.is_allowedi   s8    7###%%''227KHHHr   c                 |    |                      |           |                                                     ||          S r=   )r:   r   get_failuresr?   s      r   rC   zAxesProxyHandler.get_failuresn   s8    7###%%''44WkJJJr   c                 p    |                      |            |                                 j        |||fi |S r=   )r:   r   user_login_failed)r   senderr;   r9   kwargss        r   rE   z"AxesProxyHandler.user_login_faileds   sO     	7###9s%%''9K
 
,2
 
 	
r   c                 p    |                      |            |                                 j        |||fi |S r=   )r:   r   user_logged_inr   rF   r9   userrG   s        r   rI   zAxesProxyHandler.user_logged_in{   sD     	7###6s%%''6vwWWPVWWWr   c                 p    |                      |            |                                 j        |||fi |S r=   )r:   r   user_logged_outrJ   s        r   rM   z AxesProxyHandler.user_logged_out   sD     	7###7s%%''7XXQWXXXr   c                 B     |                                  j        |fi |S r=   )r   post_save_access_attemptr   instancerG   s      r   rO   z)AxesProxyHandler.post_save_access_attempt   s,     As%%''@TTVTTTr   c                 B     |                                  j        |fi |S r=   )r   post_delete_access_attemptrP   s      r   rS   z+AxesProxyHandler.post_delete_access_attempt   s,     Cs%%''B8VVvVVVr   )Fr=   )__name__
__module____qualname____doc__r   classmethodboolr
   r   r   strintr    r%   r(   r+   staticmethodr:   dictr>   rA   rC   r   rE   rI   rM   rO   rS    r   r   r   r      s?       	 	 N	" 	"t 	" 	" 	" 	" [	"  %)"&$	
 	
 	
 SM	
 3-		

 	
 
	
 	
 	
 [	
 59 F F FXc] Fc F F F [F =A N N NXc] Nc N N N [N 6:
 
 

&.sm
	
 
 
 [
 , , \,, H HXd^ Ht H H H [H I Ihtn I I I I [I K K K# K K K [K 
 
D 
 
 
 Z [
 X X Z [X Y Y Z [Y U U Z [U W W Z [W W Wr   r   N)loggingr   typingr   django.utils.module_loadingr   django.utils.timezoner   	axes.confr   axes.handlers.baser   r	   r
   axes.helpersr   r   r   r   r   rT   r/   r   r^   r   r   <module>rf      s!               5 5 5 5 5 5 % % % % % %       P P P P P P P P P P              ixW xW xW xW xW*O xW xW xW xW xWr   