ó
    ²Rj $  ã                   óZ  • 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S9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)Úngettext)Úmaxsizec                  ó4   • [        [        R                  5      $ ©N)Úget_password_validatorsr   ÚAUTH_PASSWORD_VALIDATORS© ó    ÚSD:\diplom_project\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_textsr6   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>)r6   r   r   )r(   r5   Ú
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                   ó2   • \ rS rSrSrSS jrS	S j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)ÚselfrE   s     r   Ú__init__ÚMinimumLengthValidator.__init__h   s   € Ø$�r   Nc                 óŽ   • [        U5      U R                  :  a,  [        [        SSU R                  5      SSU R                  0S9eg )NzNThis password is too short. It must contain at least %(min_length)d character.zOThis password is too short. It must contain at least %(min_length)d characters.Úpassword_too_shortrE   ©ÚcodeÚparams)ÚlenrE   r   r   ©rF   r&   r'   s      r   r%   ÚMinimumLengthValidator.validatek   sN   € Üˆx‹=˜4Ÿ?™?Ó*Ü!Üð0ð1à—O‘Oóð *Ø$ d§o¡oÐ6ñ
ð 
ð +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.rE   )r   rE   ©rF   s    r   r4   Ú$MinimumLengthValidator.get_help_texty   s/   € ÜØKØLØ�O‰Oó
ð ˜4Ÿ?™?Ð+ñ	,ð 	,r   rD   )é   r   )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rG   r%   r4   Ú__static_attributes__r   r   r   rA   rA   c   s   † ñô%ôõ,r   rA   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.
é   é
   )rN   )r&   Úmax_similarityÚvalueÚpwd_lenÚlength_bound_similarityÚ	value_lens         r   Úexceeds_maximum_length_ratiorc   �   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	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Ú
ValueErrorr^   )rF   rl   r^   s      r   rG   Ú)UserAttributeSimilarityValidator.__init__­   s"   € Ø.ÔØ˜CÓÜÐBÓCÐCØ,Õr   Nc                 óH  • 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[        [!        S5      SSU0S9e   Mê     g ! [         a    Un N+f = f)Nz\W+)r/   Úbz4The password is too similar to the %(verbose_name)s.Úpassword_too_similarÚverbose_namerK   )Úlowerrl   r2   Ú
isinstanceÚstrÚreÚsplitrc   r^   r   Úquick_ratioÚ_metaÚ	get_fieldrr   r   r   Ú_)	rF   r&   r'   Úattribute_namer_   Úvalue_lowerÚvalue_partsÚ
value_partrr   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ó(˜ô
 *ÜÐPÓQØ3Ø .°Ð=ñð ó *ò 3øô& -ó 6Ø'5šð6ús   Ã.DÄD!Ä D!c                 ó   • [        S5      $ )NuH   Your password canâ€™t be too similar to your other personal information.©r{   rR   s    r   r4   Ú.UserAttributeSimilarityValidator.get_help_textÓ   s   € ÜØVó
ð 	
r   )r^   rl   r   )
rU   rV   rW   rX   rY   ÚDEFAULT_USER_ATTRIBUTESrG   r%   r4   rZ   r   r   r   re   re   Ÿ   s%   † ñ	ð OÐà'>Èsô -ôõ@
r   re   c                   óD   • \ rS rSrSr\S 5       r\4S jrS	S j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 (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ÚparentrR   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)rF   Úpassword_list_pathÚfÚxs       r   rG   Ú 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  [        [	        S5      SS9eg )NzThis password is too common.Úpassword_too_common©rL   )rs   r“   r”   r   r{   rO   s      r   r%   Ú CommonPasswordValidator.validateò   s<   € Ø�>‰>Ó×!Ñ!Ó# t§~¡~Ó5Ü!ÜÐ0Ó1Ø*ñð ð 6r   c                 ó   • [        S5      $ )Nu2   Your password canâ€™t be a commonly used password.r‚   rR   s    r   r4   Ú%CommonPasswordValidator.get_help_textù   s   € ÜÐEÓFÐFr   )r”   r   )rU   rV   rW   rX   rY   r	   rŒ   rG   r%   r4   rZ   r   r   r   r†   r†   Ù   s3   † ñð ñKó ðKð +Eô 8ôõGr   r†   c                   ó(   • \ rS rSrSrSS jrS rSrg)ÚNumericPasswordValidatoréý   z5
Validate that the password is not entirely numeric.
Nc                 óT   • UR                  5       (       a  [        [        S5      SS9eg )Nz"This password is entirely numeric.Úpassword_entirely_numericrœ   )Úisdigitr   r{   rO   s      r   r%   Ú!NumericPasswordValidator.validate  s/   € Ø×Ñ×ÑÜ!ÜÐ6Ó7Ø0ñð ð r   c                 ó   • [        S5      $ )Nu*   Your password canâ€™t be entirely numeric.r‚   rR   s    r   r4   Ú&NumericPasswordValidator.get_help_text	  s   € ÜÐ=Ó>Ð>r   r   r   )rU   rV   rW   rX   rY   r%   r4   rZ   r   r   r   r¡   r¡   ý   s   † ñôõ?r   r¡   )NNr   )'Ú	functoolsr‘   rv   Ú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   Ú	lru_cacher   r   r+   r-   r6   r?   ru   Ú"password_validators_help_text_htmlrA   rc   re   r†   r¡   r   r   r   Ú<module>r´      s¯   ðÛ Û Û 	Ý #Ý å  ÷ñ ÷
 :ß ;Ý 5Ý 1Ý -ð ×Ò˜TÑ"ñFó #ðFòô &ô&	)ô	ô	Hñ &*Ð*MÈsÓ%SÐ "÷,ñ ,ò<M÷<7
ñ 7
÷t!Gñ !G÷H?ò ?r   