ó
    \š‘hŸ%  ã                   óR  • S SK r S SKrS SKrS SKJr  S SKJr  S SKJr  S SK	J
r
JrJr  S SKJrJr  S SKJrJr  S SKJr  S S	KJr  S S
KJr  \ R2                  S 5       rS rSS jrSS jrSS jrSS jr\" \\ 5      r! " S S5      r"S r# " S S5      r$ " S S5      r% " S S5      r&g)é    N)ÚSequenceMatcher)ÚPath)Úsettings)ÚFieldDoesNotExistÚImproperlyConfiguredÚValidationError)Úcached_propertyÚlazy)Úformat_htmlÚformat_html_join)Úimport_string)Úgettext)Úngettextc                  ó4   • [        [        R                  5      $ ©N)Úget_password_validatorsr   ÚAUTH_PASSWORD_VALIDATORS© ó    ÚkC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\django/contrib/auth/password_validation.pyÚget_default_password_validatorsr      s   € ä"¤8×#DÑ#DÓEÐEr   c                 óÈ   • / nU  H9  n [        US   5      nUR                  U" S0 UR	                  S0 5      D65        M;     U$ ! [         a    Sn[        XBS   -  5      ef = f)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Û%ˆ	ð	@Ü! )¨FÑ"3Ó4ˆEð 	×Ñ™%Ñ? )§-¡-°	¸2Ó">Ñ?Ö@ñ &ð Ðøô ó 	@ð4ð ô ' s°vÑ->Ñ'>Ó?Ð?ð	@ús   ‰AÁA!c                 óÎ   • / nUc
  [        5       nU H  n UR                  X5        M     U(       a  [        U5      eg! [         a  nUR                  U5         SnAMM  SnAff = f)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*   )   sk   € ð €FØÑ"Ü=Ó?ÐÛ(ˆ	ð	!Ø×Ñ˜xÖ.ñ )ö
 Ü˜fÓ%Ð%ð øô ó 	!Ø�M‰M˜%× Ò ûð	!ús   –>¾
A$ÁAÁA$c                 ó\   • Uc
  [        5       nU H  n[        USS 5      nU" X5        M     g)zm
Inform all validators that have implemented a password_changed() method
that the password has been changed.
NÚpassword_changedc                  ó   • g r   r   )Úas    r   Ú<lambda>Ú"password_changed.<locals>.<lambda>D   s   € ÈTr   )r   Úgetattr)r%   r&   r'   r    r,   s        r   r,   r,   <   s5   € ð
 Ñ"Ü=Ó?ÐÛ(ˆ	Ü" 9Ð.@Á/ÓRÐÙ˜Ö(ò )r   c                 ót   • / nU c
  [        5       n U  H"  nUR                  UR                  5       5        M$     U$ )z?
Return a list of all help texts of all configured validators.
)r   r   Úget_help_text)r'   Ú
help_textsr    s      r   Úpassword_validators_help_textsr5   H   s?   € ð €JØÑ"Ü=Ó?ÐÛ(ˆ	Ø×Ñ˜)×1Ñ1Ó3Ö4ñ )àÐr   c                 ój   • [        U 5      n[        SSS U 5       5      nU(       a  [        SU5      $ S$ )zT
Return an HTML string with all help texts of all configured validators
in an <ul>.
Ú z<li>{}</li>c              3   ó&   #   • U  H  o4v •  M	     g 7fr   r   )Ú.0Ú	help_texts     r   Ú	<genexpr>Ú6_password_validators_help_text_html.<locals>.<genexpr>[   s   é € ÐEº*¨Y�Lº*ùs   ‚z<ul>{}</ul>)r5   r   r   )r'   r4   Ú
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                   ó8   • \ rS rSrSrS	S jrS
S jrS rS rSr	g)ÚMinimumLengthValidatoréc   z4
Validate that the password is of a minimum length.
c                 ó   • Xl         g r   ©Ú
min_length)ÚselfrD   s     r   Ú__init__ÚMinimumLengthValidator.__init__h   s   € Ø$�r   Nc                 ó€   • [        U5      U R                  :  a%  [        U R                  5       SSU R                  0S9eg )NÚpassword_too_shortrD   ©ÚcodeÚparams)ÚlenrD   r   Úget_error_message©rE   r%   r&   s      r   r$   ÚMinimumLengthValidator.validatek   s?   € Üˆx‹=˜4Ÿ?™?Ó*Ü!Ø×&Ñ&Ó(Ø)Ø$ d§o¡oÐ6ñð ð +r   c                 óJ   • [        SSU R                  5      U R                  -  $ )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   rD   ©rE   s    r   rN   Ú(MinimumLengthValidator.get_error_messages   s*   € äØTØUØ—‘óð
 �o‰oñð	
r   c                 óN   • [        SSU R                  5      SU R                  0-  $ )Nz=Your password must contain at least %(min_length)d character.z>Your password must contain at least %(min_length)d characters.rD   rR   rS   s    r   r3   Ú$MinimumLengthValidator.get_help_text}   s/   € ÜØKØLØ�O‰Oó
ð ˜4Ÿ?™?Ð+ñ	,ð 	,r   rC   )é   r   )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rF   r$   rN   r3   Ú__static_attributes__r   r   r   r@   r@   c   s   † ñô%ôò
õ,r   r@   c                 ód   • [        U 5      nUS-  U-  n[        U5      nUSU-  :¬  =(       a    XT:  $ )ay  
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.
é   é
   )rM   )r%   Úmax_similarityÚvalueÚpwd_lenÚlength_bound_similarityÚ	value_lens         r   Úexceeds_maximum_length_ratiorf   …   s=   € ô0 �(‹m€GØ,¨qÑ0°7Ñ:ÐÜ�E“
€IØ�b˜9‘nÑ$×L¨Ñ)LÐLr   c                   ó@   • \ rS rSrSrSr\S4S jrSS jrS rS	 r	S
r
g)Ú UserAttributeSimilarityValidatoré£   a�  
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                 ó>   • Xl         US:  a  [        S5      eX l        g )Ngš™™™™™¹?z#max_similarity must be at least 0.1)Úuser_attributesÚ
ValueErrorra   )rE   ro   ra   s      r   rF   Ú)UserAttributeSimilarityValidator.__init__±   s"   € Ø.ÔØ˜CÓÜÐBÓCÐCØ,Õr   Nc                 óR  • U(       d  g UR                  5       nU R                   Hí  n[        X#S 5      nU(       a  [        U[        5      (       d  M-  UR                  5       n[
        R                  " SU5      U/-   nU H�  n[        XR                  U5      (       a  M   [        XS9R                  5       U R                  :¼  d  MG   [	        UR                  R                  U5      R                  5      n[        U R!                  5       SSU0S9e   Mï     g ! [         a    Un N0f = f)Nz\W+)r.   ÚbÚpassword_too_similarÚverbose_namerJ   )Úlowerro   r1   Ú
isinstanceÚstrÚreÚsplitrf   ra   r   Úquick_ratioÚ_metaÚ	get_fieldru   r   r   rN   )	rE   r%   r&   Úattribute_namerb   Úvalue_lowerÚvalue_partsÚ
value_partru   s	            r   r$   Ú)UserAttributeSimilarityValidator.validate·   s  € ÞØà—>‘>Ó#ˆØ"×2Ô2ˆNÜ˜D°$Ó7ˆEÞ¤
¨5´#× 6Ñ 6ÙØŸ+™+›-ˆKÜŸ(š( 6¨;Ó7¸;¸-ÑGˆKÛ)�
Ü/Ø×1Ñ1°:÷ñ ñ ä# hÑ=×IÑIÓKØ×*Ñ*õ+ð6Ü'*Ø ŸJ™J×0Ñ0°Ó@×MÑMó(˜ô
 *Ø×.Ñ.Ó0Ø3Ø .°Ð=ñð ó *ò 3øô& -ó 6Ø'5šð6ús   Ã.DÄD&Ä%D&c                 ó   • [        S5      $ )Nz4The password is too similar to the %(verbose_name)s.©Ú_rS   s    r   rN   Ú2UserAttributeSimilarityValidator.get_error_message×   s   € ÜÐGÓHÐHr   c                 ó   • [        S5      $ )NuH   Your password canâ€™t be too similar to your other personal information.r„   rS   s    r   r3   Ú.UserAttributeSimilarityValidator.get_help_textÚ   s   € ÜØVó
ð 	
r   )ra   ro   r   )rX   rY   rZ   r[   r\   ÚDEFAULT_USER_ATTRIBUTESrF   r$   rN   r3   r]   r   r   r   rh   rh   £   s+   † ñ	ð OÐà'>Èsô -ôò@Iõ
r   rh   c                   óJ   • \ rS rSrSr\S 5       r\4S jrS
S jrS r	S r
S	rg)ÚCommonPasswordValidatoréà   a¥  
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   • [        [        5      R                  5       R                  S-  $ )Nzcommon-passwords.txt.gz)r   Ú__file__ÚresolveÚparentrS   s    r   ÚDEFAULT_PASSWORD_LIST_PATHÚ2CommonPasswordValidator.DEFAULT_PASSWORD_LIST_PATHë   s!   € ä”H‹~×%Ñ%Ó'×.Ñ.Ð1JÑJÐJr   c                 óº  • U[         R                  L a  U R                  n [        R                  " USSS9 nU Vs1 s H  o3R	                  5       iM     snU l        S S S 5        g s  snf ! , (       d  f       g = f! [         aT    [        U5       nU Vs1 s H  o3R	                  5       iM     Os  snf snU l        S S S 5         g ! , (       d  f        g = ff = f)NÚrtzutf-8)Úencoding)r‹   r‘   ÚgzipÚopenÚstripÚ	passwordsÚOSError)rE   Úpassword_list_pathÚfÚxs       r   rF   Ú CommonPasswordValidator.__init__ï   s§   € ØÔ!8×!SÑ!SÒSØ!%×!@Ñ!@Ðð	8Ü—’Ð-¨t¸gÒFÈ!Ù56Ó!7²Q°§'¡'¦)±QÑ!7�”÷ GÐFùÚ!7÷ GÕFûäó 	8ÜÐ(Ô)¨QÙ56Ó!7²Q°§'¡'¦)²QùÔ!7�”÷ *×)×)Ð)úð	8úsc   ¡A< ·A+¼A&ÁA+ÁA< Á&A+Á+
A9Á5A< Á9A< Á<CÂCÂB0Â/CÂ=CÃ
C	ÃCÃCNc                 óŒ   • UR                  5       R                  5       U R                  ;   a  [        U R	                  5       SS9eg )NÚpassword_too_common©rK   )rv   r˜   r™   r   rN   rO   s      r   r$   Ú CommonPasswordValidator.validateù   s?   € Ø�>‰>Ó×!Ñ!Ó# t§~¡~Ó5Ü!Ø×&Ñ&Ó(Ø*ñð ð 6r   c                 ó   • [        S5      $ )NzThis password is too common.r„   rS   s    r   rN   Ú)CommonPasswordValidator.get_error_message   s   € ÜÐ/Ó0Ð0r   c                 ó   • [        S5      $ )Nu2   Your password canâ€™t be a commonly used password.r„   rS   s    r   r3   Ú%CommonPasswordValidator.get_help_text  s   € ÜÐEÓFÐFr   )r™   r   )rX   rY   rZ   r[   r\   r	   r‘   rF   r$   rN   r3   r]   r   r   r   r‹   r‹   à   s8   † ñð ñKó ðKð +Eô 8ôò1õGr   r‹   c                   ó.   • \ rS rSrSrSS jrS rS rSrg)	ÚNumericPasswordValidatori  z5
Validate that the password is not entirely numeric.
Nc                 ó^   • UR                  5       (       a  [        U R                  5       SS9eg )NÚpassword_entirely_numericr¡   )Úisdigitr   rN   rO   s      r   r$   Ú!NumericPasswordValidator.validate  s2   € Ø×Ñ×ÑÜ!Ø×&Ñ&Ó(Ø0ñð ð r   c                 ó   • [        S5      $ )Nz"This password is entirely numeric.r„   rS   s    r   rN   Ú*NumericPasswordValidator.get_error_message  s   € ÜÐ5Ó6Ð6r   c                 ó   • [        S5      $ )Nu*   Your password canâ€™t be entirely numeric.r„   rS   s    r   r3   Ú&NumericPasswordValidator.get_help_text  s   € ÜÐ=Ó>Ð>r   r   r   )	rX   rY   rZ   r[   r\   r$   rN   r3   r]   r   r   r   r¨   r¨     s   † ñôò7õ?r   r¨   )NNr   )'Ú	functoolsr–   ry   Údifflibr   Úpathlibr   Údjango.confr   Údjango.core.exceptionsr   r   r   Údjango.utils.functionalr	   r
   Údjango.utils.htmlr   r   Údjango.utils.module_loadingr   Údjango.utils.translationr   r…   r   Úcacher   r   r*   r,   r5   r>   rx   Ú"password_validators_help_text_htmlr@   rf   rh   r‹   r¨   r   r   r   Ú<module>r¼      s©   ðÛ Û Û 	Ý #Ý å  ÷ñ ÷
 :ß ;Ý 5Ý 1Ý -ð ‡�ñFó ðFòô &ô&	)ô	ô	Hñ &*Ð*MÈsÓ%SÐ "÷,ñ ,òDM÷<:
ñ :
÷z$Gñ $G÷N?ò ?r   