§
    Î“Ùh $  ã                   óz  — 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 j        d¬¦  «        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&dS )é    N)ÚSequenceMatcher)ÚPath)Úsettings)ÚFieldDoesNotExistÚImproperlyConfiguredÚValidationError)Úcached_propertyÚlazy)Úformat_htmlÚformat_html_join)Úimport_string)Úgettext)Úngettext)Úmaxsizec                  ó4   — t          t          j        ¦  «        S ©N)Úget_password_validatorsr   ÚAUTH_PASSWORD_VALIDATORS© ó    úf/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/django/contrib/auth/password_validation.pyÚget_default_password_validatorsr      s   € å"¥8Ô#DÑEÔEÐEr   c                 óð   — g }| D ]p}	 t          |d         ¦  «        }n(# t          $ r d}t          ||d         z  ¦  «        ‚w xY w|                      |di |                     di ¦  «        ¤Ž¦  «         Œq|S )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ð 	Aˆ	ð	@Ý! )¨FÔ"3Ñ4Ô4ˆEˆEøÝð 	@ð 	@ð 	@ð4ð õ ' s¨Y°vÔ->Ñ'>Ñ?Ô?Ð?ð	@øøøð 	×Ò˜%˜%Ð?Ð? )§-¢-°	¸2Ñ">Ô">Ð?Ð?Ñ@Ô@Ð@Ð@àÐs	   ˆž%Ac                 óÜ   — g }|€t          ¦   «         }|D ]E}	 |                     | |¦  «         Œ# t          $ r}|                     |¦  «         Y d}~Œ>d}~ww xY w|rt          |¦  «        ‚dS )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+   )   s¨   € ð €FØÐ"Ý=Ñ?Ô?ÐØ(ð !ð !ˆ	ð	!Ø×Ò˜x¨Ñ.Ô.Ð.Ð.øÝð 	!ð 	!ð 	!Ø�MŠM˜%Ñ Ô Ð Ð Ð Ð Ð Ð øøøøð	!øøøàð &Ý˜fÑ%Ô%Ð%ð&ð &s   ˜/¯
A¹AÁAc                 ól   — |€t          ¦   «         }|D ] }t          |dd„ ¦  «        } || |¦  «         Œ!dS )zy
    Inform all validators that have implemented a password_changed() method
    that the password has been changed.
    NÚpassword_changedc                  ó   — d S r   r   )Úas    r   ú<lambda>z"password_changed.<locals>.<lambda>D   s   € ÈT€ r   )r   Úgetattr)r&   r'   r(   r!   r-   s        r   r-   r-   <   sZ   € ð
 Ð"Ý=Ñ?Ô?ÐØ(ð )ð )ˆ	Ý" 9Ð.@À/À/ÑRÔRÐØÐ˜ 4Ñ(Ô(Ð(Ð(ð)ð )r   c                 ó‚   — g }| €t          ¦   «         } | D ])}|                     |                     ¦   «         ¦  «         Œ*|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_textsr5   H   sS   € ð €JØÐ"Ý=Ñ?Ô?ÐØ(ð 5ð 5ˆ	Ø×Ò˜)×1Ò1Ñ3Ô3Ñ4Ô4Ð4Ð4ØÐr   c                 ó~   — t          | ¦  «        }t          ddd„ |D ¦   «         ¦  «        }|rt          d|¦  «        n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V — Œd S r   r   )Ú.0Ú	help_texts     r   ú	<genexpr>z6_password_validators_help_text_html.<locals>.<genexpr>[   s$   è è € ÐEÐE¨Y˜Y˜LÐEÐEÐEÐEÐEÐEr   z<ul>{}</ul>)r5   r   r   )r(   r4   Ú
help_itemss      r   Ú#_password_validators_help_text_htmlr=   T   sT   € õ
 0Ð0CÑDÔD€JÝ!Ø
ˆMÐEÐE¸*ÐEÑEÔEñô €Jð 6@ÐG�;�} jÑ1Ô1Ð1ÀRÐGr   c                   ó(   — e Zd ZdZdd„Zdd„Zd„ ZdS )	ÚMinimumLengthValidatorz<
    Validate that the password is of a minimum length.
    é   c                 ó   — || _         d S r   )Ú
min_length)ÚselfrB   s     r   Ú__init__zMinimumLengthValidator.__init__h   s   € Ø$ˆŒˆˆr   Nc                 ó�   — t          |¦  «        | j        k     r-t          t          dd| j        ¦  «        dd| j        i¬¦  «        ‚d S )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_shortrB   ©ÚcodeÚparams)ÚlenrB   r   r   ©rC   r&   r'   s      r   r%   zMinimumLengthValidator.validatek   s_   € Ýˆx‰=Œ=˜4œ?Ò*Ð*Ý!Ýð0ð1à”Oñô ð *Ø$ d¤oÐ6ð
ñ 
ô 
ð 
ð +Ð*r   c                 óB   — 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.rB   )r   rB   ©rC   s    r   r3   z$MinimumLengthValidator.get_help_texty   s0   € ÝØKØLØŒOñ
ô 
ð ˜4œ?Ð+ñ	,ð 	,r   )r@   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rD   r%   r3   r   r   r   r?   r?   c   sU   € € € € € ðð ð%ð %ð %ð %ðð ð ð ð,ð ,ð ,ð ,ð ,r   r?   c                 ól   — t          | ¦  «        }|dz  |z  }t          |¦  «        }|d|z  k    o||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.
    é   é
   )rJ   )r&   Úmax_similarityÚvalueÚpwd_lenÚlength_bound_similarityÚ	value_lens         r   Úexceeds_maximum_length_ratiorZ   �   sD   € õ0 �(‰mŒm€GØ,¨qÑ0°7Ñ:ÐÝ�E‘
”
€IØ�b˜9‘nÒ$ÐL¨Ð5LÒ)LÐLr   c                   ó0   — e Zd ZdZdZedfd„Zdd„Zd„ ZdS )	Ú 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                 óL   — || _         |dk     rt          d¦  «        ‚|| _        d S )Ngš™™™™™¹?z#max_similarity must be at least 0.1)Úuser_attributesÚ
ValueErrorrU   )rC   rb   rU   s      r   rD   z)UserAttributeSimilarityValidator.__init__­   s2   € Ø.ˆÔØ˜CÒÐÝÐBÑCÔCÐCØ,ˆÔÐÐr   Nc                 óL  — |sd S |                      ¦   «         }| j        D �]}t          ||d ¦  «        }|rt          |t          ¦  «        sŒ,|                      ¦   «         }t          j        d|¦  «        |gz   }|D ]¦}t          || j        |¦  «        rŒt          ||¬¦  «         
                    ¦   «         | j        k    ra	 t	          |j                             |¦  «        j        ¦  «        }n# t          $ r |}Y nw xY wt          t!          d¦  «        dd|i¬¦  «        ‚Œ§�Œd S )Nz\W+)r/   Úbz4The password is too similar to the %(verbose_name)s.Úpassword_too_similarÚverbose_namerG   )Úlowerrb   r1   Ú
isinstanceÚstrÚreÚsplitrZ   rU   r   Úquick_ratioÚ_metaÚ	get_fieldrg   r   r   Ú_)	rC   r&   r'   Úattribute_namerV   Úvalue_lowerÚvalue_partsÚ
value_partrg   s	            r   r%   z)UserAttributeSimilarityValidator.validate³   sr  € Øð 	ØˆFà—>’>Ñ#Ô#ˆØ"Ô2ð 	ñ 	ˆNÝ˜D .°$Ñ7Ô7ˆEØð ¥
¨5µ#Ñ 6Ô 6ð ØØŸ+š+™-œ-ˆKÝœ( 6¨;Ñ7Ô7¸;¸-ÑGˆKØ)ð ð �
Ý/Ø˜dÔ1°:ñô ð ð å# h°*Ð=Ñ=Ô=×IÒIÑKÔKØÔ*ò+ð +ð6Ý'*Ø œJ×0Ò0°Ñ@Ô@ÔMñ(ô (˜˜øõ -ð 6ð 6ð 6Ø'5˜˜˜ð6øøøå)ÝÐPÑQÔQØ3Ø .°Ð=ðñ ô ð ð+ñð	ð 	s   Ã,C.Ã.C=Ã<C=c                 ó    — t          d¦  «        S )NuH   Your password canâ€™t be too similar to your other personal information.©rp   rM   s    r   r3   z.UserAttributeSimilarityValidator.get_help_textÓ   s   € ÝØVñ
ô 
ð 	
r   r   )rN   rO   rP   rQ   ÚDEFAULT_USER_ATTRIBUTESrD   r%   r3   r   r   r   r\   r\   Ÿ   sd   € € € € € ð	ð 	ð OÐà'>Èsð -ð -ð -ð -ðð ð ð ð@
ð 
ð 
ð 
ð 
r   r\   c                   ó@   — e Zd ZdZed„ ¦   «         Zefd„Zdd„Zd„ ZdS )Ú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 (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                 ó^   — t          t          ¦  «                             ¦   «         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                 óJ  — |t           j        u r| j        }	 t          j        |dd¬¦  «        5 }d„ |D ¦   «         | _        d d d ¦  «         d S # 1 swxY w Y   d S # t
          $ r> t          |¦  «        5 }d„ |D ¦   «         | _        d d d ¦  «         Y d S # 1 swxY w Y   Y d S w xY w)NÚrtzutf-8)Úencodingc                 ó6   — h | ]}|                      ¦   «         ’ŒS r   ©Ústrip©r9   Úxs     r   ú	<setcomp>z3CommonPasswordValidator.__init__.<locals>.<setcomp>í   ó    € Ð!7Ð!7Ð!7° !§'¢'¡)¤)Ð!7Ð!7Ð!7r   c                 ó6   — h | ]}|                      ¦   «         ’ŒS r   rƒ   r…   s     r   r‡   z3CommonPasswordValidator.__init__.<locals>.<setcomp>ð   rˆ   r   )ry   r~   ÚgzipÚopenÚ	passwordsÚOSError)rC   Úpassword_list_pathÚfs      r   rD   z CommonPasswordValidator.__init__è   sW  € ØÕ!8Ô!SÐSÐSØ!%Ô!@Ðð	8Ý”Ð-¨t¸gÐFÑFÔFð 8È!Ø!7Ð!7°QÐ!7Ñ!7Ô!7�”ð8ð 8ð 8ñ 8ô 8ð 8ð 8ð 8ð 8ð 8ð 8ð 8øøøð 8ð 8ð 8ð 8ð 8ð 8øåð 	8ð 	8ð 	8ÝÐ(Ñ)Ô)ð 8¨QØ!7Ð!7°QÐ!7Ñ!7Ô!7�”ð8ð 8ð 8ñ 8ô 8ð 8ð 8ð 8ð 8ð 8ð 8ð 8ð 8øøøð 8ð 8ð 8ð 8ð 8ð 8ð 8ð	8øøøsX   —A ®AÁ A ÁAÁA ÁAÁA ÁB"Á3BÂB"ÂB	ÂB"ÂB	ÂB"Â!B"Nc                 óœ   — |                      ¦   «                              ¦   «         | j        v rt          t	          d¦  «        d¬¦  «        ‚d S )NzThis password is too common.Úpassword_too_common©rH   )rh   r„   rŒ   r   rp   rK   s      r   r%   z CommonPasswordValidator.validateò   sS   € Ø�>Š>ÑÔ×!Ò!Ñ#Ô# t¤~Ð5Ð5Ý!ÝÐ0Ñ1Ô1Ø*ðñ ô ð ð 6Ð5r   c                 ó    — t          d¦  «        S )Nu2   Your password canâ€™t be a commonly used password.rv   rM   s    r   r3   z%CommonPasswordValidator.get_help_textù   s   € ÝÐEÑFÔFÐFr   r   )	rN   rO   rP   rQ   r	   r~   rD   r%   r3   r   r   r   ry   ry   Ù   s~   € € € € € ðð ð ðKð Kñ „_ðKð +Eð 8ð 8ð 8ð 8ðð ð ð ðGð Gð Gð Gð Gr   ry   c                   ó    — e Zd ZdZdd„Zd„ ZdS )ÚNumericPasswordValidatorz=
    Validate that the password is not entirely numeric.
    Nc                 ój   — |                      ¦   «         rt          t          d¦  «        d¬¦  «        ‚d S )Nz"This password is entirely numeric.Úpassword_entirely_numericr’   )Úisdigitr   rp   rK   s      r   r%   z!NumericPasswordValidator.validate  sF   € Ø×ÒÑÔð 	Ý!ÝÐ6Ñ7Ô7Ø0ðñ ô ð ð	ð 	r   c                 ó    — t          d¦  «        S )Nu*   Your password canâ€™t be entirely numeric.rv   rM   s    r   r3   z&NumericPasswordValidator.get_help_text	  s   € ÝÐ=Ñ>Ô>Ð>r   r   )rN   rO   rP   rQ   r%   r3   r   r   r   r•   r•   ý   sA   € € € € € ðð ðð ð ð ð?ð ?ð ?ð ?ð ?r   r•   )NNr   )'Ú	functoolsrŠ   rk   Údifflibr   Úpathlibr   Údjango.confr   Údjango.core.exceptionsr   r   r   Údjango.utils.functionalr	   r
   Údjango.utils.htmlr   r   Údjango.utils.module_loadingr   Údjango.utils.translationr   rp   r   Ú	lru_cacher   r   r+   r-   r5   r=   rj   Ú"password_validators_help_text_htmlr?   rZ   r\   ry   r•   r   r   r   ú<module>r¥      s`  ðØ Ð Ð Ð Ø €€€Ø 	€	€	€	Ø #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð à  Ð  Ð  Ð  Ð  Ð  ðð ð ð ð ð ð ð ð ð ð
 :Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø -Ð -Ð -Ð -Ð -Ð -ð €Ô˜TÐ"Ñ"Ô"ðFð Fñ #Ô"ðFðð ð ð &ð &ð &ð &ð&	)ð 	)ð 	)ð 	)ð	ð 	ð 	ð 	ð	Hð 	Hð 	Hð 	Hð &* TÐ*MÈsÑ%SÔ%SÐ "ð,ð ,ð ,ð ,ð ,ñ ,ô ,ð ,ð<Mð Mð Mð<7
ð 7
ð 7
ð 7
ð 7
ñ 7
ô 7
ð 7
ðt!Gð !Gð !Gð !Gð !Gñ !Gô !Gð !GðH?ð ?ð ?ð ?ð ?ñ ?ô ?ð ?ð ?ð ?r   