Ë
    ñ%9jŸ%  ã                   óJ  — d dl Z d dlZd dl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 d dlmZmZ d dlmZ d d	lmZ d d
lmZ e j2                  d„ «       Zd„ Zdd„Zdd„Zdd„Zdd„Z eee «      Z! G d„ d«      Z"d„ Z# G d„ d«      Z$ G d„ d«      Z% G d„ d«      Z&y)é    N)ÚSequenceMatcher)ÚPath)Úsettings)ÚFieldDoesNotExistÚImproperlyConfiguredÚValidationError)Úcached_propertyÚlazy)Úformat_htmlÚformat_html_join)Úimport_string)Úgettext)Úngettextc                  ó4   — t        t        j                  «      S ©N)Úget_password_validatorsr   ÚAUTH_PASSWORD_VALIDATORS© ó    úc/var/www/html/truck-me/venv/lib/python3.12/site-packages/django/contrib/auth/password_validation.pyÚget_default_password_validatorsr      s   € ä"¤8×#DÑ#DÓEÐEr   c                 óÄ   — g }| D ]8  }	 t        |d   «      }|j                   |di |j	                  di «      ¤Ž«       Œ: |S # t        $ r d}t        ||d   z  «      ‚w xY w)NÚNAMEzZThe module in NAME could not be imported: %s. Check your AUTH_PASSWORD_VALIDATORS setting.ÚOPTIONSr   )r   ÚImportErrorr   ÚappendÚget)Úvalidator_configÚ
validatorsÚ	validatorÚklassÚmsgs        r   r   r      sŒ   € Ø€JØ%ò 	Aˆ	ð	@Ü! )¨FÑ"3Ó4ˆEð 	×Ñ™%Ñ? )§-¡-°	¸2Ó">Ñ?Õ@ð	Að Ðøô ò 	@ð4ð ô ' s¨Y°vÑ->Ñ'>Ó?Ð?ð	@ús   ‰AÁAc                 ó¼   — g }|€
t        «       }|D ]  }	 |j                  | |«       Œ |rt        |«      ‚y# t        $ r}|j                  |«       Y d}~ŒEd}~ww xY w)zÅ
    Validate that the password meets all validator requirements.

    If the password is valid, return ``None``.
    If the password is invalid, raise ValidationError with all error messages.
    N)r   Úvalidater   r   )ÚpasswordÚuserÚpassword_validatorsÚerrorsr    Úerrors         r   Úvalidate_passwordr*   )   sr   € ð €FØÐ"Ü=Ó?ÐØ(ò !ˆ	ð	!Ø×Ñ˜x¨Õ.ð!ñ
 Ü˜fÓ%Ð%ð øô ò 	!Ø�M‰M˜%× Ñ ûð	!ús   •7·	AÁ AÁAc                 óX   — |€
t        «       }|D ]  }t        |dd„ «      } || |«       Œ y)zy
    Inform all validators that have implemented a password_changed() method
    that the password has been changed.
    NÚpassword_changedc                   ó   — y r   r   )Úas    r   ú<lambda>z"password_changed.<locals>.<lambda>D   s   � r   )r   Úgetattr)r%   r&   r'   r    r,   s        r   r,   r,   <   s<   € ð
 Ð"Ü=Ó?ÐØ(ò )ˆ	Ü" 9Ð.@Á/ÓRÐÙ˜ 4Õ(ñ)r   c                 ón   — g }| €
t        «       } | D ]!  }|j                  |j                  «       «       Œ# |S )zG
    Return a list of all help texts of all configured validators.
    )r   r   Úget_help_text)r'   Ú
help_textsr    s      r   Úpassword_validators_help_textsr4   H   sD   € ð €JØÐ"Ü=Ó?ÐØ(ò 5ˆ	Ø×Ñ˜)×1Ñ1Ó3Õ4ð5àÐr   c                 ó`   — t        | «      }t        ddd„ |D «       «      }|rt        d|«      S dS )z`
    Return an HTML string with all help texts of all configured validators
    in an <ul>.
    Ú z<li>{}</li>c              3   ó"   K  — | ]  }|f–— Œ	 y ­wr   r   )Ú.0Ú	help_texts     r   ú	<genexpr>z6_password_validators_help_text_html.<locals>.<genexpr>[   s   è ø€ ÒE¨Y˜YœLÑEùs   ‚z<ul>{}</ul>)r4   r   r   )r'   r3   Ú
help_itemss      r   Ú#_password_validators_help_text_htmlr<   T   s=   € ô
 0Ð0CÓD€JÜ!Ø
ˆMÑE¸*ÔEó€Jñ 6@Œ;�} jÓ1ÐGÀRÐGr   c                   ó,   — e Zd ZdZdd„Zdd„Zd„ Zd„ Zy)	ÚMinimumLengthValidatorz<
    Validate that the password is of a minimum length.
    c                 ó   — || _         y r   )Ú
min_length)Úselfr@   s     r   Ú__init__zMinimumLengthValidator.__init__h   s	   € Ø$ˆ�r   Nc                 ó„   — t        |«      | j                  k  r(t        | j                  «       dd| j                  i¬«      ‚y )NÚpassword_too_shortr@   ©ÚcodeÚparams)Úlenr@   r   Úget_error_message©rA   r%   r&   s      r   r$   zMinimumLengthValidator.validatek   s?   € Üˆx‹=˜4Ÿ?™?Ò*Ü!Ø×&Ñ&Ó(Ø)Ø$ d§o¡oÐ6ôð ð +r   c                 óJ   — t        dd| j                  «      | j                  z  S )NzBThis password is too short. It must contain at least %d character.zCThis password is too short. It must contain at least %d characters.©r   r@   ©rA   s    r   rI   z(MinimumLengthValidator.get_error_messages   s*   € äØTØUØ—‘óð
 �o‰oñð	
r   c                 óN   — t        dd| j                  «      d| j                  iz  S )Nz=Your password must contain at least %(min_length)d character.z>Your password must contain at least %(min_length)d characters.r@   rL   rM   s    r   r2   z$MinimumLengthValidator.get_help_text}   s/   € ÜØKØLØ�O‰Oó
ð ˜4Ÿ?™?Ð+ñ	,ð 	,r   )é   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rB   r$   rI   r2   r   r   r   r>   r>   c   s   „ ñó%óò
ó,r   r>   c                 ó\   — t        | «      }|dz  |z  }t        |«      }|d|z  k\  xr ||k  S )a½  
    Test that value is within a reasonable range of password.

    The following ratio calculations are based on testing SequenceMatcher like
    this:

    for i in range(0,6):
      print(10**i, SequenceMatcher(a='A', b='A'*(10**i)).quick_ratio())

    which yields:

    1 1.0
    10 0.18181818181818182
    100 0.019801980198019802
    1000 0.001998001998001998
    10000 0.00019998000199980003
    100000 1.999980000199998e-05

    This means a length_ratio of 10 should never yield a similarity higher than
    0.2, for 100 this is down to 0.02 and for 1000 it is 0.002. This can be
    calculated via 2 / length_ratio. As a result we avoid the potentially
    expensive sequence matching.
    é   é
   )rH   )r%   Úmax_similarityÚvalueÚpwd_lenÚlength_bound_similarityÚ	value_lens         r   Úexceeds_maximum_length_ratior\   …   s@   € ô0 �(‹m€GØ,¨qÑ0°7Ñ:ÐÜ�E“
€IØ�b˜9‘nÑ$ÒL¨Ð5LÑ)LÐLr   c                   ó4   — e Zd ZdZdZedfd„Zd	d„Zd„ Zd„ Zy)
Ú UserAttributeSimilarityValidatora¯  
    Validate that the password is sufficiently different from the user's
    attributes.

    If no specific attributes are provided, look at a sensible list of
    defaults. Attributes that don't exist are ignored. Comparison is made to
    not only the full attribute value, but also its components, so that, for
    example, a password is validated against either part of an email address,
    as well as the full address.
    )ÚusernameÚ
first_nameÚ	last_nameÚemailgffffffæ?c                 ó@   — || _         |dk  rt        d«      ‚|| _        y )Ngš™™™™™¹?z#max_similarity must be at least 0.1)Úuser_attributesÚ
ValueErrorrW   )rA   rd   rW   s      r   rB   z)UserAttributeSimilarityValidator.__init__±   s&   € Ø.ˆÔØ˜CÒÜÐBÓCÐCØ,ˆÕr   Nc                 ó*  — |sy |j                  «       }| j                  D ]à  }t        ||d «      }|rt        |t        «      sŒ#|j                  «       }t        j                  d|«      |gz   }|D ]�  }t        || j                  |«      rŒt        ||¬«      j                  «       | j                  k\  sŒD	 t	        |j                  j                  |«      j                  «      }t        | j!                  «       dd|i¬«      ‚ Œâ y # t        $ r |}Y Œ/w xY w)Nz\W+)r.   ÚbÚpassword_too_similarÚverbose_namerE   )Úlowerrd   r0   Ú
isinstanceÚstrÚreÚsplitr\   rW   r   Úquick_ratioÚ_metaÚ	get_fieldri   r   r   rI   )	rA   r%   r&   Úattribute_namerX   Úvalue_lowerÚvalue_partsÚ
value_partri   s	            r   r$   z)UserAttributeSimilarityValidator.validate·   s  € ÙØà—>‘>Ó#ˆØ"×2Ñ2ò 	ˆNÜ˜D .°$Ó7ˆEÙ¤
¨5´#Ô 6ØØŸ+™+›-ˆKÜŸ(™( 6¨;Ó7¸;¸-ÑGˆKØ)ò �
Ü/Ø˜d×1Ñ1°:ôð ä# h°*Ô=×IÑIÓKØ×*Ñ*ó+ð6Ü'*Ø ŸJ™J×0Ñ0°Ó@×MÑMó(˜ô
 *Ø×.Ñ.Ó0Ø3Ø .°Ð=ôð ññ	øô& -ò 6Ø'5šð6ús   Â4.DÄDÄDc                 ó   — t        d«      S )Nz4The password is too similar to the %(verbose_name)s.©Ú_rM   s    r   rI   z2UserAttributeSimilarityValidator.get_error_message×   s   € ÜÐGÓHÐHr   c                 ó   — t        d«      S )NuH   Your password canâ€™t be too similar to your other personal information.rw   rM   s    r   r2   z.UserAttributeSimilarityValidator.get_help_textÚ   s   € ÜØVó
ð 	
r   r   )	rP   rQ   rR   rS   ÚDEFAULT_USER_ATTRIBUTESrB   r$   rI   r2   r   r   r   r^   r^   £   s+   „ ñ	ð OÐà'>Èsó -óò@Ió
r   r^   c                   ó>   — e Zd ZdZed„ «       Zefd„Zdd„Zd„ Zd„ Z	y)	ÚCommonPasswordValidatoraÁ  
    Validate that the password is not a common password.

    The password is rejected if it occurs in a provided list of passwords,
    which may be gzipped. The list Django ships with contains 20000 common
    passwords (unhexed, lowercased and deduplicated), created by Royce Williams:
    https://gist.github.com/roycewilliams/226886fd01572964e1431ac8afc999ce
    The password list must be lowercased to match the comparison in validate().
    c                 óV   — t        t        «      j                  «       j                  dz  S )Nzcommon-passwords.txt.gz)r   Ú__file__ÚresolveÚparentrM   s    r   ÚDEFAULT_PASSWORD_LIST_PATHz2CommonPasswordValidator.DEFAULT_PASSWORD_LIST_PATHë   s!   € ä”H‹~×%Ñ%Ó'×.Ñ.Ð1JÑJÐJr   c                 óž  — |t         j                  u r| j                  }	 t        j                  |dd¬«      5 }|D �ch c]  }|j	                  «       ’Œ c}| _        d d d «       y c c}w # 1 sw Y   y xY w# t        $ rM t        |«      5 }|D �ch c]  }|j	                  «       ’Œ nc c}w c}| _        d d d «       Y y # 1 sw Y   Y y xY ww xY w)NÚrtzutf-8)Úencoding)r|   r�   ÚgzipÚopenÚstripÚ	passwordsÚOSError)rA   Úpassword_list_pathÚfÚxs       r   rB   z CommonPasswordValidator.__init__ï   s³   € ØÔ!8×!SÑ!SÑSØ!%×!@Ñ!@Ðð	8Ü—‘Ð-¨t¸gÔFð 8È!Ø56Ö!7° !§'¡'¥)Ò!7�”÷8ð 8ùÚ!7÷8ð 8ûäò 	8ÜÐ(Ó)ð 8¨QØ56Ö!7° !§'¡'¥)Ñ!7ùÔ!7�”÷8÷ 8ó 8úð	8úsc    A6 ¸A*½A%ÁA*ÁA6 Á%A*Á*A3Á/A6 Á3A6 Á6CÂ
B>ÂB'Â&B>Â4CÂ>C	ÃCÃCNc                 óŽ   — |j                  «       j                  «       | j                  v rt        | j	                  «       d¬«      ‚y )NÚpassword_too_common©rF   )rj   r‡   rˆ   r   rI   rJ   s      r   r$   z CommonPasswordValidator.validateù   s?   € Ø�>‰>Ó×!Ñ!Ó# t§~¡~Ñ5Ü!Ø×&Ñ&Ó(Ø*ôð ð 6r   c                 ó   — t        d«      S )NzThis password is too common.rw   rM   s    r   rI   z)CommonPasswordValidator.get_error_message   s   € ÜÐ/Ó0Ð0r   c                 ó   — t        d«      S )Nu2   Your password canâ€™t be a commonly used password.rw   rM   s    r   r2   z%CommonPasswordValidator.get_help_text  s   € ÜÐEÓFÐFr   r   )
rP   rQ   rR   rS   r	   r�   rB   r$   rI   r2   r   r   r   r|   r|   à   s8   „ ñð ñKó ðKð +Eó 8óò1óGr   r|   c                   ó$   — e Zd ZdZdd„Zd„ Zd„ Zy)ÚNumericPasswordValidatorz=
    Validate that the password is not entirely numeric.
    Nc                 óZ   — |j                  «       rt        | j                  «       d¬«      ‚y )NÚpassword_entirely_numericr�   )Úisdigitr   rI   rJ   s      r   r$   z!NumericPasswordValidator.validate  s/   € Ø×ÑÔÜ!Ø×&Ñ&Ó(Ø0ôð ð r   c                 ó   — t        d«      S )Nz"This password is entirely numeric.rw   rM   s    r   rI   z*NumericPasswordValidator.get_error_message  s   € ÜÐ5Ó6Ð6r   c                 ó   — t        d«      S )Nu*   Your password canâ€™t be entirely numeric.rw   rM   s    r   r2   z&NumericPasswordValidator.get_help_text  s   € ÜÐ=Ó>Ð>r   r   )rP   rQ   rR   rS   r$   rI   r2   r   r   r   r“   r“     s   „ ñóò7ó?r   r“   )NNr   )'Ú	functoolsr…   rm   Údifflibr   Úpathlibr   Údjango.confr   Údjango.core.exceptionsr   r   r   Údjango.utils.functionalr	   r
   Údjango.utils.htmlr   r   Údjango.utils.module_loadingr   Údjango.utils.translationr   rx   r   Úcacher   r   r*   r,   r4   r<   rl   Ú"password_validators_help_text_htmlr>   r\   r^   r|   r“   r   r   r   ú<module>r¤      s©   ðÛ Û Û 	Ý #Ý å  ÷ñ ÷
 :ß ;Ý 5Ý 1Ý -ð ‡�ñFó ðFòó &ó&	)ó	ó	Hñ &*Ð*MÈsÓ%SÐ "÷,ñ ,òDM÷<:
ñ :
÷z$Gñ $G÷N?ò ?r   