ó
    |ch  ã                   óØ   • S r SSKrSSKrSSKJrJr  SSKJr  SSKJ	r
  SSKJrJr  S r " S S	\5      r " S
 S5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)z+
Provides various authentication policies.
é    N)ÚauthenticateÚget_user_model)ÚCsrfViewMiddleware)Úgettext_lazy)ÚHTTP_HEADER_ENCODINGÚ
exceptionsc                 ó’   • U R                   R                  SS5      n[        U[        5      (       a  UR	                  [
        5      nU$ )z}
Return request's 'Authorization:' header, as a bytestring.

Hide some test client ickyness where the header can be unicode.
ÚHTTP_AUTHORIZATIONó    )ÚMETAÚgetÚ
isinstanceÚstrÚencoder   )ÚrequestÚauths     Úf/var/www/djangovue.mamus.xyz/django/venv/lib/python3.13/site-packages/rest_framework/authentication.pyÚget_authorization_headerr      s<   € ð �<‰<×ÑÐ0°#Ó6€DÜ�$œ×Ñà�{‰{Ô/Ó0ˆØ€Kr   c                   ó   • \ rS rSrS rSrg)Ú	CSRFChecké   c                 ó   • U$ ©N© )Úselfr   Úreasons      r   Ú_rejectÚCSRFCheck._reject   s   € àˆr   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   Ú__static_attributes__r   r   r   r   r      s   † õr   r   c                   ó$   • \ rS rSrSrS rS rSrg)ÚBaseAuthenticationé!   z>
All authentication classes should extend BaseAuthentication.
c                 ó   • [        S5      e)zC
Authenticate the request and return a two-tuple of (user, token).
z#.authenticate() must be overridden.)ÚNotImplementedError©r   r   s     r   r   ÚBaseAuthentication.authenticate&   s   € ô "Ð"GÓHÐHr   c                 ó   • g)zÇ
Return a string to be used as the value of the `WWW-Authenticate`
header in a `401 Unauthenticated` response, or `None` if the
authentication scheme should return `403 Permission Denied` responses.
Nr   r)   s     r   Úauthenticate_headerÚ&BaseAuthentication.authenticate_header,   s   € ð 	r   r   N)r   r    r!   r"   Ú__doc__r   r,   r#   r   r   r   r%   r%   !   s   † ñòIõr   r%   c                   ó2   • \ rS rSrSrSrS rS	S jrS rSr	g)
ÚBasicAuthenticationé5   z6
HTTP Basic authentication against username/password.
Úapic                 óÔ  • [        U5      R                  5       nU(       a  US   R                  5       S:w  a  g[        U5      S:X  a!  [	        S5      n[
        R                  " U5      e[        U5      S:”  a!  [	        S5      n[
        R                  " U5      e  [        R                  " US   5      R                  S5      nUR                  S
S5      u  pVU R                  XVU5      $ ! [         a+    [        R                  " US   5      R                  S	5      n NZf = f! [        [        [        [        R                  4 a"    [	        S5      n[
        R                  " U5      ef = f)z„
Returns a `User` if a correct username and password have been supplied
using HTTP Basic authentication.  Otherwise returns `None`.
r   s   basicNé   z.Invalid basic header. No credentials provided.é   zCInvalid basic header. Credentials string should not contain spaces.zutf-8zlatin-1Ú:z?Invalid basic header. Credentials not correctly base64 encoded.)r   ÚsplitÚlowerÚlenÚ_r   ÚAuthenticationFailedÚbase64Ú	b64decodeÚdecodeÚUnicodeDecodeErrorÚ	TypeErrorÚ
ValueErrorÚbinasciiÚErrorÚauthenticate_credentials)r   r   r   ÚmsgÚauth_decodedÚuseridÚpasswords          r   r   Ú BasicAuthentication.authenticate;   s>  € ô
 (¨Ó0×6Ñ6Ó8ˆæ�t˜A‘w—}‘}“¨(Ó2Øäˆt‹9˜‹>ÜÐDÓEˆCÜ×1Ò1°#Ó6Ð6Ü�‹Y˜‹]ÜÐYÓZˆCÜ×1Ò1°#Ó6Ð6ð		7ðKÜ%×/Ò/°°Q±Ó8×?Ñ?ÀÓH�ð  ,×1Ñ1°#°qÓ9ÑˆFð
 ×,Ñ,¨V¸wÓGÐGøô &ó KÜ%×/Ò/°°Q±Ó8×?Ñ?À	ÓJ’ðKûô œ:Ô'9¼8¿>¹>ÐJó 	7ÜÐUÓVˆCÜ×1Ò1°#Ó6Ð6ð	7ús+   Â(C) ÃD! Ã)2DÄD! ÄDÄD! Ä!AE'Nc                 óø   • [        5       R                  USU0n[        SSU0UD6nUc  [        R                  " [        S5      5      eUR                  (       d  [        R                  " [        S5      5      eUS4$ )zg
Authenticate the userid and password against username and password
with optional request for context.
rH   r   NzInvalid username/password.úUser inactive or deleted.r   )r   ÚUSERNAME_FIELDr   r   r;   r:   Ú	is_active)r   rG   rH   r   ÚcredentialsÚusers         r   rD   Ú,BasicAuthentication.authenticate_credentialsY   sv   € ô Ó×+Ñ+¨VØ˜ð
ˆô Ñ; GÐ;¨{Ñ;ˆà‰<Ü×1Ò1´!Ð4PÓ2QÓRÐRà�~�~Ü×1Ò1´!Ð4OÓ2PÓQÐQà�dˆ|Ðr   c                 ó    • SU R                   -  $ )NzBasic realm="%s")Úwww_authenticate_realmr)   s     r   r,   Ú'BasicAuthentication.authenticate_headerl   s   € Ø! D×$?Ñ$?Ñ?Ð?r   r   r   )
r   r    r!   r"   r.   rR   r   rD   r,   r#   r   r   r   r0   r0   5   s    † ñð #ÐòHô<õ&@r   r0   c                   ó$   • \ rS rSrSrS rS rSrg)ÚSessionAuthenticationép   z4
Use Django's session framework for authentication.
c                 óŒ   • [        UR                  SS5      nU(       a  UR                  (       d  gU R                  U5        US4$ )zc
Returns a `User` if the request session currently has a logged in user.
Otherwise returns `None`.
rO   N)ÚgetattrÚ_requestrM   Úenforce_csrf©r   r   rO   s      r   r   Ú"SessionAuthentication.authenticateu   s@   € ô �w×'Ñ'¨°Ó6ˆö ˜4Ÿ>Ÿ>Øà×Ñ˜'Ô"ð �dˆ|Ðr   c                 óª   • S n[        U5      nUR                  U5        UR                  USS0 5      nU(       a  [        R                  " SU-  5      eg)z;
Enforce CSRF validation for session based authentication.
c                 ó   • g r   r   )r   s    r   Údummy_get_responseÚ>SessionAuthentication.enforce_csrf.<locals>.dummy_get_response‹   s   € Ør   Nr   zCSRF Failed: %s)r   Úprocess_requestÚprocess_viewr   ÚPermissionDenied)r   r   r_   Úcheckr   s        r   rZ   Ú"SessionAuthentication.enforce_csrf‡   sW   € ò	ô Ð,Ó-ˆà×Ñ˜gÔ&Ø×#Ñ# G¨T°2°rÓ:ˆÞä×-Ò-Ð.?À&Ñ.HÓIÐIð r   r   N)r   r    r!   r"   r.   r   rZ   r#   r   r   r   rU   rU   p   s   † ñòõ$Jr   rU   c                   ó:   • \ rS rSrSrSrSrS r S rS r	S r
S	rg)
ÚTokenAuthenticationé—   zó
Simple token based authentication.

Clients should authenticate by passing the token key in the "Authorization"
HTTP header, prepended with the string "Token ".  For example:

    Authorization: Token 401f7ac837da42b97f613d789819ff93537bee6a
ÚTokenNc                 óD   • U R                   b  U R                   $ SSKJn  U$ )Nr   )ri   )ÚmodelÚrest_framework.authtoken.modelsri   )r   ri   s     r   Ú	get_modelÚTokenAuthentication.get_model¤   s   € Ø�:‰:Ñ!Ø—:‘:ÐÝ9Øˆr   c                 ó&  • [        U5      R                  5       nU(       a=  US   R                  5       U R                  R                  5       R	                  5       :w  a  g [        U5      S:X  a!  [        S5      n[        R                  " U5      e[        U5      S:”  a!  [        S5      n[        R                  " U5      e US   R                  5       nU R                  U5      $ ! [         a"    [        S5      n[        R                  " U5      ef = f)Nr   r4   z.Invalid token header. No credentials provided.r5   z=Invalid token header. Token string should not contain spaces.zIInvalid token header. Token string should not contain invalid characters.)r   r7   r8   Úkeywordr   r9   r:   r   r;   r>   ÚUnicodeErrorrD   )r   r   r   rE   Útokens        r   r   Ú TokenAuthentication.authenticate±   så   € Ü'¨Ó0×6Ñ6Ó8ˆæ�t˜A‘w—}‘}“¨$¯,©,×*<Ñ*<Ó*>×*EÑ*EÓ*GÓGØäˆt‹9˜‹>ÜÐDÓEˆCÜ×1Ò1°#Ó6Ð6Ü�‹Y˜‹]ÜÐSÓTˆCÜ×1Ò1°#Ó6Ð6ð	7Ø˜‘G—N‘NÓ$ˆEð
 ×,Ñ,¨UÓ3Ð3øô	 ó 	7ÜÐ_Ó`ˆCÜ×1Ò1°#Ó6Ð6ð	7ús   Ã C$ Ã$,Dc                 ój  • U R                  5       n UR                  R                  S5      R                  US9nUR                  R                  (       d  [
        R                  " [        S5      5      eUR                  U4$ ! UR                   a     [
        R                  " [        S5      5      ef = f)NrO   )ÚkeyzInvalid token.rK   )
rm   ÚobjectsÚselect_relatedr   ÚDoesNotExistr   r;   r:   rO   rM   )r   ru   rk   rr   s       r   rD   Ú,TokenAuthentication.authenticate_credentialsÆ   s›   € Ø—‘Ó ˆð	GØ—M‘M×0Ñ0°Ó8×<Ñ<ÀÐ<ÐEˆEð �z‰z×#×#Ü×1Ò1´!Ð4OÓ2PÓQÐQà—
‘
˜EÐ"Ð"øð ×!Ñ!ó 	GÜ×1Ò1´!Ð4DÓ2EÓFÐFð	Gús   ’(B Â0B2c                 ó   • U R                   $ r   )rp   r)   s     r   r,   Ú'TokenAuthentication.authenticate_headerÒ   s   € Ø�|‰|Ðr   r   )r   r    r!   r"   r.   rp   rk   rm   r   rD   r,   r#   r   r   r   rg   rg   —   s,   † ñð €GØ€Eòðò4ò*
#õr   rg   c                   ó"   • \ rS rSrSrSrS rSrg)ÚRemoteUserAuthenticationéÖ   a   
REMOTE_USER authentication.

To use this, set up your web server to perform authentication, which will
set the REMOTE_USER environment variable. You will need to have
'django.contrib.auth.backends.RemoteUserBackend in your
AUTHENTICATION_BACKENDS setting
ÚREMOTE_USERc                 ó–   • [        XR                  R                  U R                  5      S9nU(       a  UR                  (       a  US 4$ g g )N)r   Úremote_user)r   r   r   ÚheaderrM   r[   s      r   r   Ú%RemoteUserAuthentication.authenticateå   s9   € Ü G¿¹×9IÑ9IÈ$Ï+É+Ó9VÑWˆÞ�D—N—NØ˜$�<Ðð #ˆ4r   r   N)r   r    r!   r"   r.   r‚   r   r#   r   r   r   r}   r}   Ö   s   † ñð €Fõ r   r}   )r.   r<   rB   Údjango.contrib.authr   r   Údjango.middleware.csrfr   Údjango.utils.translationr   r:   Úrest_frameworkr   r   r   r   r%   r0   rU   rg   r}   r   r   r   Ú<module>rˆ      su   ðñó Û ç <Ý 5Ý 6ç ;ò
ôÐ"ô ÷ñ ô(8@Ð,ô 8@ôv$JÐ.ô $JôN<Ð,ô <ô~ Ð1õ  r   