
    Uњh                     j    S SK Jr  S SKJr  S SKJr  S SKJrJr   " S S\5      r	 " S S\5      r
\
/rg	)
    )HttpResponseRedirect)reverse)	urlencode)ProviderProviderAccountc                       \ rS rSrSrg)SAMLAccount    N)__name__
__module____qualname____firstlineno____static_attributes__r       hD:\Anime\Ugyen\janka_web_project\venv\Lib\site-packages\allauth/socialaccount/providers/saml/provider.pyr	   r	      s    r   r	   c                      ^  \ rS rSrSrSrSr\rS/SS/S/S	S
/S/S/S.r	U 4S jr
S rS rS rS rS rSS jrSrU =r$ )SAMLProvider   samlSAMLTz,urn:oasis:names:tc:SAML:attribute:subject-idz!urn:oid:0.9.2342.19200300.100.1.3zBhttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddressz'http://schemas.auth0.com/email_verifiedz?http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givennamezurn:oid:2.5.4.42zurn:oid:2.5.4.4z!http://schemas.auth0.com/nickname)uidemailemail_verified
first_name	last_nameusernamec                    > [         TU ]  " U0 UD6  U R                  R                  =(       d)    U R                  R                  =(       d    U R                  U l        g N)super__init__appname	client_id)selfargskwargs	__class__s      r   r!   SAMLProvider.__init__(   s<    $)&)HHMMDTXX%7%7D499	r   c                 v    [        SSU R                  R                  0S9nU(       a  US-   [        U5      -   nU$ )N
saml_loginorganization_slug)r'   ?)r   r"   r$   r   )r%   requestr'   urls       r   get_login_urlSAMLProvider.get_login_url,   s9    l,?ASAS+TU)i//C
r   c                 "    UR                  5       $ r   )get_attributes)r%   datas     r   extract_extra_dataSAMLProvider.extract_extra_data2   s    ""$$r   c                 l    U R                  U5      R                  S5      nUc  UR                  5       nU$ )u/  http://docs.oasis-open.org/security/saml-subject-id-attr/v1.0/csprd01/saml-subject-id-attr-v1.0-csprd01.html

Quotes:

"While the Attributes defined in this profile have as a goal the
explicit replacement of the <saml:NameID> element as a means of subject
identification, it is certainly possible to compose them with existing
NameID usage provided the same subject is being identified. This can
also serve as a migration strategy for existing applications."


"SAML does not define an identifier that meets all of these
requirements well. It does standardize a kind of NameID termed
“persistent” that meets some of them in the particular case of so-called
“pairwise” identification, where an identifier varies by relying
party. It has seen minimal adoption outside of a few contexts, and fails
at the “compact” and “simple to handle” criteria above, on top of the
disadvantages inherent with all NameID usage."

Overall, our strategy is to prefer a uid resulting from explicit
attribute mappings, and only if there is no such uid fallback to the
NameID.
r   )_extractget
get_nameid)r%   r4   r   s      r   extract_uidSAMLProvider.extract_uid5   s3    0 mmD!%%e,;//#C
r   c                 L    U R                  U5      nUR                  SS 5        U$ )Nr   )r8   pop)r%   r4   rets      r   extract_common_fields"SAMLProvider.extract_common_fieldsR   s#    mmD!t
r   c                 h   U R                   R                  nUR                  5       n0 nUR                  SU R                  5      nUR                  5        HV  u  pg[        U[        5      (       a  U/nU H3  nUR                  US 5      n	U	c  M  [        U	5      S:  d  M+  U	S   XF'     MT     MX     UR                  S5      n
U
(       a  U
R                  5       S;   n
XS'   UR                  S5      (       d>  UR                  5       S:X  d  UR                  SS5      (       a  UR                  5       US'   U$ )	Nattribute_mappingr   r   )true1tyyesr   z6urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddressuse_nameid_for_emailF)r"   settingsr3   r9   default_attribute_mappingitems
isinstancestrlenlowerget_nameid_formatr:   )r%   r4   provider_configraw_attributes
attributesrC   keyprovider_keysprovider_keyattribute_listr   s              r   r8   SAMLProvider._extractW   s-   ((++,,.
+//!?!?
 #4"9"9";C---!. -!/!3!3L$!G!-#n2E2I&4Q&7JO	 !. #< $(89+1137UUN+9'( ~~g&&""$GH ""#95AA"&//"3Jwr   c                     SSK Jn  U" X5      nUR                  SS9nU R                  " UUUU4SUR	                  5       0UD6  [        U5      $ )Nr   )
build_auth )	return_tostate_id)*allauth.socialaccount.providers.saml.utilsr[   loginstash_redirect_stateget_last_request_idr   )	r%   r.   processnext_urlr4   r'   r[   authredirects	            r   rf   SAMLProvider.redirectw   se    I'( :::+!!		

 --/	
 	
 $H--r   )r#   )NN)r   r   r   r   idr#   supports_redirectr	   account_classrK   r!   r0   r5   r;   r@   r8   rf   r   __classcell__)r(   s   @r   r   r      s    	BDM ;
 0P

 6
 N

 
 0
%!.E%:
@. .r   r   N)django.httpr   django.urlsr   django.utils.httpr   $allauth.socialaccount.providers.baser   r   r	   r   provider_classesr   r   r   <module>rq      s6    ,  ' J	/ 	z.8 z.z !> r   